<template>
  <div>
    <div class="my-1">
      <el-button
        plain
        size="small"
        type="primary"
        v-if="!hasFinish"
        v-show="!viewMode"
        @click="onFinishCencus"
      >
        <i class="fa fa-check-circle"></i>
        完成报告
      </el-button>

      <el-button plain size="small" type="primary" @click="onPrint">
        <i class="fa fa-print"></i>
        打印
      </el-button>
    </div>

    <div class="report-wrap">
      <div class="report-main" id="report-census">
        <div class="report-census">
          <div class="report-section">
            <h2 class="report-title">
              铜仁市农业信贷担保有限责任公司
              <br />
              企业担保贷款调查报告
            </h2>

            <!--<div class="font-weight-bold d-flex justify-content-end">-->
            <!--<span>项目编号：</span>-->
            <!--<el-input v-if="!hasFinish"-->
            <!--type="text"-->
            <!--size="small"-->
            <!--style="width: 160px;"-->
            <!--v-model="censusData.census_number"-->
            <!--@blur="onReportSave('census_number')"></el-input>-->
            <!--<span v-else>{{censusData.census_number}}</span>-->
            <!--</div>-->

            <div
              style="
                font-size: 1.25rem;
                font-family: SimSun;
                margin-bottom: 5rem;
                display: flex;
                justify-content: flex-end;
              "
            >
              <span>项目编号：</span>
              <div v-if="!hasFinish" class="d-flex" style="max-width: 200px">
                <span>{{ censusNumberPrefix }}</span>
                <span>-</span>
                <input
                  style="
                    display: inline-block;
                    padding: 0;
                    border: none;
                    background-color: #ffffee;
                    width: 60px;
                    text-align: center;
                    font-size: 1.25rem;
                    height: 26px;
                  "
                  class="form-control"
                  placeholder="XXXX"
                  v-model="censusNumberYear"
                  @input="onCensusNumberYearInput"
                  @blur="onCensusNumberYearBlur"
                />
                <span>-</span>
                <input
                  style="
                    display: inline-block;
                    padding: 0;
                    border: none;
                    background-color: #ffffee;
                    width: 50px;
                    text-align: center;
                    font-size: 1.25rem;
                    height: 26px;
                  "
                  class="form-control"
                  placeholder="XXX"
                  ref="censusNumberSerial"
                  v-model="censusNumberSerial"
                  @input="onCensusNumberSerialInput"
                  @blur="onCensusNumberSerialBlur"
                  @keyup.enter.stop="$refs.censusNumberNext.focus()"
                />
              </div>
              <span v-else>{{ censusData.census_number }}</span>
            </div>

            <h3 align="center" class="report-section-title">项目基本信息</h3>
            <table class="table table-bordered">
              <colgroup>
                <col width="15%" />
                <col width="22%" />
                <col width="20%" />
                <col width="22%" />
                <col width="21%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>客户姓名</td>
                  <td colspan="3">{{ relatedData.corp_name || '-' }}</td>
                </tr>
                <tr>
                  <td>企业名称</td>
                  <td colspan="3">{{ relatedData.customer_name || '-' }}</td>
                </tr>
                <tr>
                  <td>借款主体</td>
                  <td colspan="3">{{ infoData.load_main_entity || '-' }}</td>
                </tr>
                <tr>
                  <td>借款银行</td>
                  <td colspan="3" class="report-input-td">
                    <!-- <span v-if="bankenumData.bank_name">{{relatedData.bank_name}}</span> -->
                    <select-bank
                      v-if="!hasFinish"
                      class="w-100"
                      v-model="censusData.bank_code"
                      @change="name => onReportSave('bank_code', name)"
                    ></select-bank>
                    <span v-else>{{ relatedData.bank_name || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>业务品种</td>
                  <td colspan="3" class="report-input-td">
                    <el-input
                      v-if="!hasFinish"
                      class="text-center"
                      ref="censusNumberNext"
                      v-model="censusData.business_type"
                      @blur="onReportSave('business_type')"
                    ></el-input>
                    <span v-else>{{ censusData.business_type || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>申请担保金额(万元)</td>
                  <td>{{ relatedData.apply_funds }}</td>
                  <td>申请担保期限(年)</td>
                  <td class="report-input-td">
                    <input
                      v-if="!hasFinish"
                      v-model="censusData.warranty_period"
                      class="form-control d-print-none"
                      step="1"
                      type="number"
                      @blur="onReportSave('warranty_period')"
                    />
                    <span v-else>{{ censusData.warranty_period || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>银行借款利率</td>
                  <td class="report-input-td">
                    <div v-if="!hasFinish" class="input-group">
                      <input
                        v-model="censusData.bank_rate"
                        class="form-control d-print-none base-bank-rate"
                        min="0"
                        type="number"
                        @blur="onReportSave('bank_rate')"
                      />
                      <div class="input-group-append">
                        <span class="input-group-text">%</span>
                      </div>
                    </div>
                    <span v-else>{{ censusData.bank_rate || '-' }}%</span>
                  </td>
                  <td>担保费率</td>
                  <td class="report-input-td">
                    <div v-if="!hasFinish" class="input-group">
                      <input
                        v-model="censusData.warranty_rate"
                        class="form-control"
                        min="0"
                        type="number"
                        @blur="onReportSave('warranty_rate')"
                      />
                      <div class="input-group-append">
                        <span class="input-group-text">%</span>
                      </div>
                    </div>
                    <span v-else>{{ censusData.warranty_rate || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>贷款用途</td>
                  <td colspan="3">{{ relatedData.funds_use_dir || '-' }}</td>
                </tr>
                <tr>
                  <td>反担保方式</td>
                  <td colspan="3" class="report-input-td">
                    <el-input
                      v-if="!hasFinish"
                      class="text-center"
                      v-model="dataLevelReview.warranty_method"
                      @blur="onLevelReviewSave('warranty_method')"
                    ></el-input>
                    <span v-else>{{ dataLevelReview.warranty_method || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>调查A角</td>
                  <td>{{ relatedData.res_a_name || '-' }}</td>
                  <td>调查B角</td>
                  <td>{{ relatedData.res_b_name || '-' }}</td>
                </tr>
                <tr>
                  <td>风控人员</td>
                  <td class="report-input-td">
                    <select-staffper
                      :viewMode="hasFinish"
                      v-model="censusData.risk_control_person"
                      placeholder="选择风控人员"
                      @change="onReportSave('risk_control_person')"
                    ></select-staffper>
                  </td>
                  <td>审批人员</td>
                  <td class="report-input-td">
                    <el-input
                      v-model="censusData.approval_person"
                      v-if="!hasFinish"
                      class="text-center"
                      placeholder="审批人员"
                      type="text"
                      @blur="onReportSave('approval_person')"
                    ></el-input>
                    <span v-else>{{ censusData.approval_person || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td>受理日期</td>
                  <td class="report-input-td">
                    <el-date-picker
                      v-model="censusData.accept_date"
                      type="date"
                      v-if="!hasFinish"
                      style="width: 100%"
                      value-format="yyyy-MM-dd"
                      placeholder="受理日期"
                      @blur="onReportSave('accept_date')"
                    ></el-date-picker>
                    <span v-else>
                      <span v-if="censusData.accept_date">
                        {{ $utils.dateFormat(censusData.accept_date, 'yyyy.MM.dd') }}
                      </span>
                      <span v-else>-</span>
                    </span>
                  </td>
                  <td>调查日期</td>
                  <td class="report-input-td">
                    <el-date-picker
                      v-model="censusData.survey_date"
                      type="date"
                      v-if="!hasFinish"
                      style="width: 100%"
                      value-format="yyyy-MM-dd"
                      placeholder="调查日期"
                      @blur="onReportSave('survey_date')"
                    ></el-date-picker>
                    <span v-else>
                      <span v-if="censusData.survey_date">
                        {{ $utils.dateFormat(censusData.survey_date, 'yyyy.MM.dd') }}
                      </span>
                      <span v-else>-</span>
                    </span>
                  </td>
                </tr>
                <tr>
                  <td colspan="4" class="text-center font-weight-bold">
                    重要性说明：此报告是按照相关制度规定，根据担保申请人提供和信贷人员收集的资料，经我们实地认真调查、核实、分析和整理后完成的报表自填我们对报告内容的真实性、准确性、完整性和相关结论负责报表自填
                  </td>
                </tr>
              </tbody>
            </table>

            <hr class="line" />
            <h3 class="report-section-title">一、企业非财务情况分析</h3>

            <h4 class="report-section-subtitle">1.企业法人情况：</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="15%" />
                <col width="14%" />
                <col width="14%" />
                <col width="14%" />
                <col width="15%" />
                <col width="14%" />
                <col width="14%" />
              </colgroup>
              <tbody>
                <tr>
                  <td class="font-weight-bold">姓名</td>
                  <td>{{ shareholderData.real_name || '-' }}</td>
                  <td class="font-weight-bold">身份证号</td>
                  <td>{{ shareholderData.id_card || '-' }}</td>
                  <td class="font-weight-bold">联系电话</td>
                  <td>{{ shareholderData.mobile_no || '-' }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">性别</td>
                  <td>{{ enumSexType[shareholderData.sex] || '-' }}</td>
                  <td class="font-weight-bold">学历</td>
                  <td>{{ enumEduType[shareholderData.education] || '-' }}</td>
                  <td class="font-weight-bold">持股比例</td>
                  <td>{{ shareholderData.sh_rate | pureUnit('%') }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">公司职位</td>
                  <td>{{ shareholderData.positio || '-' }}</td>
                  <td class="font-weight-bold">居住地址</td>
                  <td colspan="3">{{ shareholderData.address_detail || '-' }}</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2.企业基本情况：</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="15%" />
                <col width="14%" />
                <col width="14%" />
                <col width="14%" />
                <col width="15%" />
                <col width="14%" />
                <col width="14%" />
              </colgroup>
              <tbody>
                <tr>
                  <td class="font-weight-bold">企业名称</td>
                  <td>{{ relatedData.customer_name || '-' }}</td>
                  <td>统一社会信用代码</td>
                  <td>{{ infoData.register_no || '-' }}</td>
                  <td class="font-weight-bold">成立日期</td>
                  <td>{{ $utils.dateFormat(infoData.established_date, 'yyyy.MM.dd') }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">所属行业</td>
                  <td>{{ enumFarmType[relatedData.farm_type] || '-' }}</td>
                  <td class="font-weight-bold">注册资金(万元)</td>
                  <td>{{ infoData.register_funds || '-' }}</td>
                  <td class="font-weight-bold">股东人数</td>
                  <td>{{ comRateData.length }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">已投入资金</td>
                  <td>{{ relatedData.invest_total || '-' }}</td>
                  <td class="font-weight-bold">负债</td>
                  <td>{{ relatedData.en_debt || '-' }}</td>
                  <td class="font-weight-bold">最近1年销售收入</td>
                  <td>{{ relatedData.last_year_income || '-' }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">经营年限</td>
                  <td>{{ infoData.bussiness_years || '-' }}</td>
                  <td class="font-weight-bold">雇员人数</td>
                  <td>{{ employmentData.emp_total || '-' }}</td>
                  <td class="font-weight-bold">最近1年利润</td>
                  <td>{{ relatedData.last_year_profit || '-' }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">实际控制人</td>
                  <td>{{ controllerName || '-' }}</td>
                  <td class="font-weight-bold">经营地址</td>
                  <td colspan="3">{{ relatedData.address || '-' }}</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">3、企业经营历史及现状：</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.business_history"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="企业经营历史及现状"
                      rows="4"
                      type="text"
                      @blur="onReportSave('business_history')"
                    ></textarea>
                    <span v-else>{{ censusData.business_history || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">4、企业员工及管理模式描述：</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.management_model"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="企业员工及管理模式描述"
                      rows="4"
                      type="text"
                      @blur="onReportSave('management_model')"
                    ></textarea>
                    <span v-else>{{ censusData.management_model || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">5、所经营的行业、产品及经营模式描述分析：</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.business_model"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="所经营的行业、产品及经营模式描述分析"
                      rows="4"
                      type="text"
                      @blur="onReportSave('business_model')"
                    ></textarea>
                    <span v-else>{{ censusData.business_model || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">
              6、供销情况分析
              <br />
              （主要原辅材料、主要供应商、主要购货商，合作时间，结算情况）：
            </h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="font-weight-bold" :rowspan="gongData.length + 3">主要供货商</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">供应商名称</td>
                  <td class="font-weight-bold">商品及型号</td>
                  <td class="font-weight-bold">单价（元）</td>
                  <td class="font-weight-bold">数量</td>
                  <td class="font-weight-bold">金额（万元）</td>
                  <td class="font-weight-bold">联系电话</td>
                </tr>
                <tr v-for="(p, index) of gongData" :key="`gda-` + index">
                  <td>{{ p.sm_name || '-' }}</td>
                  <td>{{ p.sm_product || '-' }}</td>
                  <td>{{ p.sm_price || '-' }}</td>
                  <td>{{ p.sm_amount || '-' }}</td>
                  <td>{{ p.sm_total || '-' }}</td>
                  <td>{{ p.sm_phone || '-' }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">合计：</td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td class="font-weight-bold">{{ gongAll }}</td>
                  <td></td>
                </tr>
                <tr>
                  <td class="font-weight-bold" :rowspan="xiaodata.length + 3">主要销货商</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">客户名称</td>
                  <td class="font-weight-bold">商品及型号</td>
                  <td class="font-weight-bold">单价（元）</td>
                  <td class="font-weight-bold">数量</td>
                  <td class="font-weight-bold">金额（万元）</td>
                  <td class="font-weight-bold">联系电话</td>
                </tr>
                <tr v-for="(p, index) of xiaodata" :key="`xda-` + index">
                  <td>{{ p.sm_name || '-' }}</td>
                  <td>{{ p.sm_product || '-' }}</td>
                  <td>{{ p.sm_price || '-' }}</td>
                  <td>{{ p.sm_amount || '-' }}</td>
                  <td>{{ p.sm_total || '-' }}</td>
                  <td>{{ p.sm_phone || '-' }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">合计：</td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td class="font-weight-bold">{{ xiaoAll }}</td>
                  <td></td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">7、未来一年发展计划：</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.future_plan"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="未来一年发展计划"
                      rows="4"
                      type="text"
                      @blur="onReportSave('future_plan')"
                    ></textarea>
                    <span v-else>{{ censusData.future_plan || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">8、企业非财务情况分析结论：</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.non_finance_result"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="对企业管理、产品、市场、经营模式及发展战略的分析结论"
                      rows="4"
                      type="text"
                      @blur="onReportSave('non_finance_result')"
                    ></textarea>
                    <span v-else>{{ censusData.non_finance_result || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr class="line" />
            <h3 class="report-section-title">二、股东花名册及股东简历</h3>

            <h4 class="report-section-subtitle">1、股东花名册</h4>

            <table class="table table-bordered">
              <tbody>
                <tr class="font-weight-bold">
                  <td>股东名称</td>
                  <td>身份证号/资格证号码</td>
                  <td>类型</td>
                  <td>出资方式</td>
                  <td>认缴出资额</td>
                  <td>持股比例</td>
                  <td>缴付期限</td>
                </tr>
                <tr v-for="(p, index) in comRateData" :key="index">
                  <td>{{ p.real_name }}</td>
                  <td>{{ p.id_card }}</td>
                  <td>{{ enumCorpType[p.is_corp] }}</td>
                  <td>{{ p.invest_method }}</td>
                  <td>{{ p.invest_funds | pureUnit('万元') }}</td>
                  <td>{{ p.sh_rate | pureUnit('%') }}</td>
                  <td>{{ $utils.dateFormat(p.invest_rate, 'yyyy.MM') }}</td>
                </tr>
                <tr v-if="!comRateData.length">
                  <td>-</td>
                  <td>-</td>
                  <td>-</td>
                  <td>-</td>
                  <td>-</td>
                  <td>-</td>
                  <td>-</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、股东及配偶简历</h4>

            <div v-for="(p, index) in comRateData" :key="`sh-${index}`">
              <h5 class="report-section-subtitle">
                2.{{ index + 1 }} {{ p.real_name }}简历及期间积累情况
              </h5>

              <table class="table table-bordered">
                <colgroup>
                  <col width="11%" />
                  <col width="11%" />
                  <col width="11%" />
                  <col width="11%" />
                  <col width="11%" />
                  <col width="11%" />
                  <col width="12%" />
                  <col width="11%" />
                  <col width="11%" />
                </colgroup>
                <tbody>
                  <tr>
                    <td>姓名</td>
                    <td>{{ p.real_name }}</td>
                    <td>证号号码</td>
                    <td colspan="2">{{ p.id_card || '-' }}</td>
                    <td>持股比例</td>
                    <td colspan="3">{{ p.sh_rate ? `${p.sh_rate}%` : '-' }}</td>
                  </tr>
                  <tr v-if="p.is_corp !== '4'">
                    <td>性别</td>
                    <td>{{ enumSexType[p.sex] }}</td>
                    <td>学历</td>
                    <td colspan="2">{{ p.education ? enumEduType[p.education] : '-' }}</td>
                    <td>联系电话</td>
                    <td colspan="3">{{ p.mobile_no || '-' }}</td>
                  </tr>
                  <!-- <tr v-else>
                      <td>出资方式</td>
                      <td>{{p.invest_method}}</td>
                      <td>认缴出资额</td>
                      <td>{{p.invest_funds}}</td>
                      <td>缴付期限</td>
                      <td colspan="2">{{$utils.dateFormat(p.invest_rate, 'yyyy.MM')}}</td>
                    </tr> -->
                  <tr v-if="p.is_corp !== '4'">
                    <td>居住地址</td>
                    <td colspan="6">{{ p.address_detail || '-' }}</td>
                    <td>婚姻状况</td>
                    <td>{{ p.marriage_status ? enumMarrType[p.marriage_status] : '-' }}</td>
                  </tr>
                  <tr v-else>
                    <td>地址</td>
                    <td colspan="8">{{ p.address_detail || '-' }}</td>
                  </tr>

                  <template v-if="p.is_corp !== '4'">
                    <tr>
                      <td :rowspan="p.handEdu.length + 1" class="font-weight-bold">受教育经历</td>
                      <td colspan="2" class="font-weight-bold">起止时间</td>
                      <td class="font-weight-bold">年龄阶段</td>
                      <td colspan="2" class="font-weight-bold">教育机构</td>
                      <td class="font-weight-bold">专业</td>
                      <td colspan="2" class="font-weight-bold">备注</td>
                    </tr>

                    <tr v-for="(edu, j) of p.handEdu" :key="`edu-${index}-${j}`">
                      <td colspan="2">{{ edu.datePeriod }}</td>
                      <td>{{ edu.age_inter || '-' }}</td>
                      <td colspan="2">{{ edu.education_mech || '-' }}</td>
                      <td>{{ edu.profession || '-' }}</td>
                      <td colspan="2">{{ edu.remark || '-' }}</td>
                    </tr>

                    <tr>
                      <td :rowspan="p.workExp.length + 1" class="font-weight-bold">工作经历</td>
                      <td colspan="2" class="font-weight-bold">起止时间</td>
                      <td class="font-weight-bold">年龄阶段</td>
                      <td colspan="2" class="font-weight-bold">工作单位</td>
                      <td class="font-weight-bold">职务</td>
                      <td colspan="2" class="font-weight-bold">备注</td>
                    </tr>

                    <tr v-for="(job, k) of p.workExp" :key="`work-${index}-${k}`">
                      <td colspan="2">{{ job.datePeriod || '-' }}</td>
                      <td>{{ job.age_inter || '-' }}</td>
                      <td colspan="2">{{ job.work_unit || '-' }}</td>
                      <td>{{ job.job || '-' }}</td>
                      <td colspan="2">{{ job.remark || '-' }}</td>
                    </tr>
                  </template>

                  <tr>
                    <td class="font-weight-bold">资产情况</td>
                    <td colspan="8"></td>
                  </tr>

                  <template v-if="p.is_corp !== '4' && '1,2,3'.indexOf(p.marriage_status) > -1">
                    <tr>
                      <td colspan="9" class="font-weight-bold">配偶情况</td>
                    </tr>
                    <tr>
                      <td>姓名</td>
                      <td>{{ p.spouseInfo.real_name || '-' }}</td>
                      <td>身份证号码</td>
                      <td colspan="2">{{ p.spouseInfo.id_card || '-' }}</td>
                      <td>联系电话</td>
                      <td colspan="3">{{ p.spouseInfo.mobile_no || '-' }}</td>
                    </tr>
                    <tr>
                      <td>性别</td>
                      <td>{{ enumSexType[p.spouseInfo.sex] || '-' }}</td>
                      <td>学历</td>
                      <td colspan="2">
                        {{ p.spouseInfo.education ? enumEduType[p.education] : '-' }}
                      </td>
                      <td>月收入</td>
                      <td colspan="3">{{ p.spouseInfo.month_income || '-' }}</td>
                    </tr>
                    <tr>
                      <td>身份证地址</td>
                      <td colspan="8">{{ p.spouseInfo.address_detail || '-' }}</td>
                    </tr>
                    <tr>
                      <td>单位/经营行业</td>
                      <td colspan="4">{{ p.spouseInfo.positio || '-' }}</td>
                      <td colspan="2">工作/经营年限</td>
                      <td colspan="2">{{ p.spouseInfo.exp_years || '-' }}</td>
                    </tr>
                    <tr>
                      <td colspan="9" class="font-weight-bold text-center">
                        备注：{{ p.remark || '-' }}
                      </td>
                    </tr>
                  </template>
                </tbody>
              </table>
            </div>
            <hr class="line" />
            <h3 class="report-section-title">三、申请人及企业征信情况</h3>

            <h4 class="report-section-subtitle">1、企业及股东贷款状况：</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="12%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>借款人姓名</td>
                  <td>贷款银行</td>
                  <td>贷款品种</td>
                  <td>贷款金额(万元)</td>
                  <td colspan="2">贷款期限</td>
                  <td>贷款余额(万元)</td>
                  <td colspan="2">信用状况</td>
                </tr>

                <template v-for="(p, index) in topData">
                  <tr v-if="!p.creditType" :key="index">
                    <td :rowspan="p.rowspan" v-if="p.rowspan > 0" class="font-weight-bold">
                      {{ p.shareholder_name }}
                    </td>
                    <td>{{ p.loan_bank }}</td>
                    <td>{{ p.loan_variety || '-' }}</td>
                    <td>{{ p.loan_funds || '-' }}</td>
                    <td>{{ p.start_date }}</td>
                    <td>{{ p.end_date }}</td>
                    <td>{{ p.loan_left || '-' }}</td>
                    <td colspan="2">{{ p.return_situation || '-' }}</td>
                  </tr>

                  <tr v-else-if="p.creditType === 1" :key="`dot-${index}`" class="font-weight-bold">
                    <td>小计：</td>
                    <td>{{ p.creditCount }}</td>
                    <td>{{ p.fundsSum }}万元</td>
                    <td></td>
                    <td></td>
                    <td>{{ p.leftSum }}万元</td>
                    <td colspan="2"></td>
                  </tr>

                  <tr v-else-if="p.creditType === 2" :key="`dot-form-${index}`">
                    <td colspan="9" class="report-input-td">
                      <textarea
                        v-model="p.remark"
                        v-if="!hasFinish"
                        class="form-control d-print-none text-center"
                        placeholder="请填写备注"
                        rows="1"
                        type="text"
                        @blur="onCreditSave(p.remark, p.id)"
                      ></textarea>
                      <span v-else>{{ p.remark || '-' }}</span>
                    </td>
                  </tr>

                  <tr v-else-if="p.creditType === 3" :key="`dot-${index}`" class="font-weight-bold">
                    <td colspan="2">{{ p.load_num }}</td>
                    <td>{{ p.return_funds }}</td>
                    <td>{{ p.overdue_num }}</td>
                    <td colspan="2">{{ p.overdue_max_funds }}</td>
                    <td colspan="2">{{ p.overdue_max_months }}</td>
                  </tr>

                  <tr v-else-if="p.creditType === 4" :key="`dot-${index}`" class="font-weight-bold">
                    <td colspan="2">{{ p.load_num }}</td>
                    <td>{{ p.return_funds }}</td>
                    <td>{{ p.overdue_num }}</td>
                    <td>{{ p.overdue_max_funds }}</td>
                    <td>{{ p.overdue_max_funds_months }}</td>
                    <td>{{ p.overdue_max_months }}</td>
                    <td>{{ p.overdue_max_months_months }}</td>
                  </tr>
                </template>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、信用卡使用状况：</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="12%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>用卡人</td>
                  <td>账户数</td>
                  <td>授信总额(万元)</td>
                  <td>已用额度(万元)</td>
                  <td colspan="2">最近6个月平均使用额度(万元)</td>
                  <td>信用状况</td>
                </tr>
                <tr v-for="(p, index) of Carddata" :key="`car-` + index">
                  <td style="vertical-align: middle">{{ p.shareholder_name }}</td>
                  <td>{{ p.card_num || '-' }}</td>
                  <td>{{ p.loan_funds || '-' }}</td>
                  <td>{{ p.loan_left || '-' }}</td>
                  <td colspan="2">{{ p.avg_funds || '-' }}</td>
                  <td>{{ p.return_situation || '-' }}</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">3、申请人对外担保情况（含家庭成员对外担保情况）</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td>担保对象</td>
                  <td>担保期限(年)</td>
                  <td>担保额度(万元)</td>
                  <td>担保余额(万元)</td>
                  <td>备注</td>
                </tr>
                <tr v-for="(p, index) of Foreign" :key="`foreign-` + index">
                  <td>{{ p.warrant_object || '-' }}</td>
                  <td>{{ p.warrant_period || '-' }}</td>
                  <td>{{ p.warrant_funds || '-' }}</td>
                  <td>{{ p.warrant_left_funds || '-' }}</td>
                  <td>{{ p.remark || '-' }}</td>
                </tr>
              </tbody>
            </table>
            <hr class="line" />
            <h3 class="report-section-title">四、财务情况分析</h3>

            <div style="position: relative">
              <h4 class="report-section-subtitle">1、资产负债表</h4>
              <div style="position: absolute; right: 0; top: 0">单位：元</div>
            </div>

            <p v-if="!financeTable.length" class="text-center text-muted" key="finance-table">
              (暂无数据)
            </p>

            <table class="table table-bordered" v-else key="finance-table">
              <colgroup>
                <col width="20%" />
                <col width="13%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
              </colgroup>
              <tbody>
                <tr v-for="(item, index) in financeTable" :key="index" :class="[item.css || '']">
                  <td>{{ item.col1 }}</td>
                  <td>{{ item.col2 | fixed(index) }}</td>
                  <td>{{ item.col3 | fixed(index) }}</td>
                  <td>{{ item.col4 | fixed(index) }}</td>
                  <td>{{ item.col5 | fixed(index) }}</td>
                  <td>{{ item.col6 | fixed(index) }}</td>
                  <td>{{ item.col7 | fixed(index) }}</td>
                </tr>
              </tbody>
            </table>

            <div style="position: relative">
              <h4 class="report-section-subtitle">2、利润表</h4>
              <div style="position: absolute; right: 0; top: 0">单位：元</div>
            </div>

            <p v-if="!incomeStatement.length" class="text-center text-muted" key="income-statement">
              (暂无数据)
            </p>

            <table class="table table-bordered" v-else key="income-statement">
              <colgroup>
                <col width="20%" />
                <col width="13%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
              </colgroup>
              <tbody>
                <tr v-for="(item, index) in incomeStatement" :key="index" :class="[item.css || '']">
                  <td>{{ item.col1 }}</td>
                  <td>{{ item.col2 | fixed(index) }}</td>
                  <td>{{ item.col3 | fixed(index) }}</td>
                  <td>{{ item.col4 | fixed(index) }}</td>
                  <td>{{ item.col5 | fixed(index) }}</td>
                  <td>{{ item.col6 | fixed(index) }}</td>
                  <td>{{ item.col7 | fixed(index) }}</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">3、财务指标分析</h4>

            <p v-if="!financePoint.length" class="text-center text-muted" key="finance-point">
              (暂无数据)
            </p>

            <table class="table table-bordered" v-else key="finance-point">
              <colgroup>
                <col width="20%" />
                <col width="13%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
                <col width="14%" />
                <col width="13%" />
              </colgroup>
              <tbody>
                <tr v-for="(item, index) in financePoint" :key="index" :class="[item.css || '']">
                  <td>{{ item.col1 || '-' }}</td>
                  <td>{{ item.col2 || '-' }}</td>
                  <td>{{ item.col3 || '-' }}</td>
                  <td>{{ item.col4 || '-' }}</td>
                  <td>{{ item.col5 || '-' }}</td>
                  <td>{{ item.col6 || '-' }}</td>
                  <td>{{ item.col7 || '-' }}</td>
                </tr>
                <tr>
                  <td colspan="7" class="report-input-td">
                    <textarea
                      v-model="censusData.finance_remark"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="备注"
                      rows="4"
                      type="text"
                      @blur="onReportSave('finance_remark')"
                    ></textarea>
                    <span v-else>{{ censusData.finance_remark || '-' }}</span>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">4、其他关键财务信息</h4>

            <h5 class="report-section-subtitle">4.1项目基础建设资金投入明细</h5>

            <table class="table table-bordered">
              <colgroup>
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>项目</td>
                  <td>规格详情</td>
                  <td>单价（元）</td>
                  <td>金额（元）</td>
                  <td>备注</td>
                </tr>
                <tr v-for="(p, index) of twoData" :key="`two-` + index">
                  <td>{{ p.project_name }}</td>
                  <td>{{ p.uscale }}</td>
                  <td>{{ p.unit_price }}</td>
                  <td>{{ p.funds || '-' }}</td>
                  <td>{{ p.remark }}</td>
                </tr>
                <tr>
                  <td>合计</td>
                  <td>—</td>
                  <td>—</td>
                  <td>{{ twoAmount }}</td>
                  <td>-</td>
                </tr>
              </tbody>
            </table>

            <h5 class="report-section-subtitle">4.2当年流动资金支出明细</h5>

            <table class="table table-bordered">
              <colgroup>
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>项目</td>
                  <td>规格详情</td>
                  <td>单价（元）</td>
                  <td>金额（元）</td>
                  <td>备注</td>
                </tr>
                <tr v-for="(p, index) of threeData" :key="`three-` + index">
                  <td>{{ p.project_name }}</td>
                  <td>{{ p.uscale }}</td>
                  <td>{{ p.unit_price }}</td>
                  <td>{{ p.funds }}</td>
                  <td>{{ p.remark }}</td>
                </tr>
                <tr>
                  <td>合计</td>
                  <td>—</td>
                  <td>—</td>
                  <td>{{ threeAmount }}</td>
                  <td>—</td>
                </tr>
              </tbody>
            </table>

            <h5 class="report-section-subtitle">4.3项目资金来源</h5>

            <table class="table table-bordered">
              <colgroup>
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>资金来源</td>
                  <td>资金用途</td>
                  <td>金额(万元)</td>
                  <td colspan="2">备注</td>
                </tr>
                <tr v-for="(p, index) of sourcesData" :key="`sources-` + index">
                  <td>{{ p.capital_source }}</td>
                  <td>{{ p.capital_use }}</td>
                  <td>{{ p.funds }}</td>
                  <td colspan="2">{{ p.remark }}</td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">5、财务情况分析结论</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.input_remark"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="财务情况分析结论"
                      rows="4"
                      type="text"
                      @blur="onReportSave('input_remark')"
                    ></textarea>
                    <div v-else>{{ censusData.input_remark || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- <table class="table table-bordered">
                <colgroup>
                  <col width="14%">
                  <col width="14%">
                  <col width="14%">
                  <col width="14%">
                  <col width="14%">
                  <col width="15%">
                  <col width="15%">
                </colgroup>
                <tbody>
                  <tr>
                    <td colspan="6">2、主要财务指标———费用投入情况</td>
                  </tr>
                  <tr>
                    <td>资产负债率</td>
                    <td>{{normdata.assets_rate}}</td>
                    <td>流动比率</td>
                    <td>{{normdata.flow_rate}}</td>
                    <td>速动比率</td>
                    <td>{{normdata.quick_rate}}</td>
                  </tr>
                  <tr>
                    <td>应收账款周转率</td>
                    <td>{{normdata.account_rec_rate}}</td>
                    <td>存货周转率</td>
                    <td>{{normdata.inv_turn_rate}}</td>
                    <td>总资产周转率</td>
                    <td>{{normdata.assets_turn_rate}}</td>
                  </tr>
                  <tr>
                    <td>销售毛利率</td>
                    <td>{{normdata.sales_rate}}</td>
                    <td>总资产收益率</td>
                    <td>{{normdata.assets_income_rate}}</td>
                    <td>销售增长比率</td>
                    <td>{{normdata.sales_growth_rate}}</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="6">
                      <textarea v-model="censusData.finance_norm_remark"
                                class="form-control d-print-none"
                                id="form-4-2"
                                placeholder="请填写备注"
                                rows="4"
                                type="text"
                                @blur="onReportSave('finance_norm_remark')"></textarea>
                    </td>
                    <td v-else
                        colspan="6">
                      <div class="text-indent"
                           id="anchor-4-2">
                        <div v-anchor:report-edit.focus="'form-4-2'"
                             class="edit-eara">{{censusData.finance_norm_remark || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table>
              <table class="table table-bordered">
                <colgroup>
                  <col width="14%">
                  <col width="18%">
                  <col width="17%">
                  <col width="17%">
                  <col width="17%">
                  <col width="17%">
                </colgroup>
                <tbody>
                  <tr>
                    <td :rowspan="14 + sourcesData.length + twoData.length + threeData.length">项目资金投入明细</td>
                  </tr>
                  <tr>
                    <td colspan="5">3、其它主要科目明细———资金来源明细</td>
                  </tr>
                  <tr>
                    <td>资金来源</td>
                    <td>资金用途</td>
                    <td>金额(万元)</td>
                    <td colspan="2">备注</td>
                  </tr>
                  <tr v-for="(p, index) of sourcesData"
                      :key="`sources-` + index">
                    <td>{{p.capital_source}}</td>
                    <td>{{p.capital_use}}</td>
                    <td>{{p.funds}}</td>
                    <td colspan="2">{{p.remark}}</td>
                  </tr>
                  <tr>
                    <td colspan="5">4、其它主要科目明细———固定投入情况</td>
                  </tr>
                  <tr>
                    <td>项目</td>
                    <td>规格详情</td>
                    <td>单价（元）</td>
                    <td>金额（元）</td>
                    <td>备注</td>
                  </tr>
                  <tr v-for="(p, index) of twoData"
                      :key="`two-` + index">
                    <td>{{p.project_name}}</td>
                    <td>{{p.uscale}}</td>
                    <td>{{p.unit_price}}</td>
                    <td>{{p.funds || '-'}}</td>
                    <td>{{p.remark}}</td>
                  </tr>
                  <tr>
                    <td>合计</td>
                    <td>—</td>
                    <td>—</td>
                    <td>{{twoAmount}}</td>
                    <td>-</td>
                  </tr>
                  <tr>
                    <td colspan="5">5、项目流动资金投入明细</td>
                  </tr>
                  <tr>
                    <td>项目</td>
                    <td>规格详情</td>
                    <td>单价（元）</td>
                    <td>金额（元）</td>
                    <td>备注</td>
                  </tr>
                  <tr v-for="(p, index) of threeData"
                      :key="`three-` + index">
                    <td>{{p.project_name}}</td>
                    <td>{{p.uscale}}</td>
                    <td>{{p.unit_price}}</td>
                    <td>{{p.funds}}</td>
                    <td>{{p.remark}}</td>
                  </tr>
                  <tr>
                    <td>合计</td>
                    <td>—</td>
                    <td>—</td>
                    <td>{{threeAmount}}</td>
                    <td>—</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="5">
                      <textarea v-model="censusData.input_remark"
                                class="form-control d-print-none"
                                id="form-4-3"
                                placeholder="请填写备注"
                                rows="4"
                                type="text"
                                @blur="onReportSave('input_remark')"></textarea>
                    </td>
                    <td v-else
                        colspan="5">
                      <div class="text-indent"
                           id="anchor-4-3">
                        <div v-anchor:report-edit.focus="'form-4-3'"
                             class="edit-eara">{{censusData.input_remark || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table> -->
            <hr class="line" />
            <h3 class="report-section-title">五、检验核实情况</h3>

            <h4 class="report-section-subtitle">1、客户信息核实</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="12%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>基本执照</td>
                  <td>
                    可供抵押
                    <br />
                    房产
                  </td>
                  <td>
                    土地租赁
                    <br />
                    合同
                  </td>
                  <td>供销合同</td>
                  <td>电费</td>
                  <td>存货清单</td>
                  <td>货币资金</td>
                  <td>经营场所</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="postVdata.other"
                      class="form-control d-print-none"
                      placeholder="请填写类型"
                      type="text"
                      v-if="!hasFinish"
                      @blur="onVdataSave('other')"
                    ></textarea>
                    <span v-else>{{ postVdata.other || '-' }}</span>
                  </td>
                </tr>
                <tr>
                  <td v-if="!hasFinish">
                    <el-select
                      v-model="postVdata.business_normal"
                      @change="onVdataSave('business_normal')"
                    >
                      <el-option key="0" label="有" value="有"></el-option>
                      <el-option key="1" label="无" value="无"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.business_normal || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select
                      v-model="postVdata.mortgage_property"
                      @change="onVdataSave('mortgage_property')"
                    >
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.mortgage_property || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select v-model="postVdata.land_lease" @change="onVdataSave('land_lease')">
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.land_lease || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select
                      v-model="postVdata.supply_market"
                      @change="onVdataSave('supply_market')"
                    >
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.supply_market || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select v-model="postVdata.ele_fee" @change="onVdataSave('ele_fee')">
                      <el-option key="0" label="异常" value="异常"></el-option>
                      <el-option key="1" label="正常" value="正常"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.ele_fee || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select v-model="postVdata.stock" @change="onVdataSave('stock')">
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.stock || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select
                      v-model="postVdata.bank_account"
                      @change="onVdataSave('bank_account')"
                    >
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.bank_account || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select v-model="postVdata.cash" @change="onVdataSave('cash')">
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.cash || '-' }}</td>
                  <td v-if="!hasFinish">
                    <el-select v-model="postVdata.other_value" @change="onVdataSave('other_value')">
                      <el-option key="0" label="无" value="无"></el-option>
                      <el-option key="1" label="有" value="有"></el-option>
                    </el-select>
                  </td>
                  <td v-else>{{ postVdata.other_value || '-' }}</td>
                </tr>
              </tbody>
            </table>
            <h4 class="report-section-subtitle">2、第三方评价</h4>
            <table class="table table-bordered">
              <colgroup>
                <col width="10%" />
                <col width="90%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>村委会评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_burg"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="村委会评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_burg')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_burg || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>乡镇府评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_village"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="乡镇府评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_village')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_village || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>左右与邻评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_lr"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="左右与邻评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_lr')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_lr || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>同行评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_sm"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="同行评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_sm')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_sm || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>上游企业评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_upper"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="上游企业评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_upper')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_upper || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>下游企业评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_lower"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="下游企业评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_lower')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_lower || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>其他相关人、单位评价情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.third_evalue_other"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="上游企业评价情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('third_evalue_other')"
                    ></textarea>
                    <div v-else>{{ censusData.third_evalue_other || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">3、财务数据核实</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="10%" />
                <col width="90%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>资产及负债核实情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.finance_assets_verify"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="资产及负债核实情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('finance_assets_verify')"
                    ></textarea>
                    <div v-else>{{ censusData.finance_assets_verify || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>企业收入核实情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.finance_income_verify"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="企业收入核实情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('finance_income_verify')"
                    ></textarea>
                    <div v-else>{{ censusData.finance_income_verify || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>成本费用核实情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.finance_cost_verify"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="成本费用核实情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('finance_cost_verify')"
                    ></textarea>
                    <div v-else>{{ censusData.finance_cost_verify || '-' }}</div>
                  </td>
                </tr>
                <tr>
                  <td>其它科目核实情况</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.finance_other_verify"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="其它科目核实情况"
                      rows="2"
                      type="text"
                      @blur="onReportSave('finance_other_verify')"
                    ></textarea>
                    <div v-else>{{ censusData.finance_other_verify || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">4、银行流水分析</h4>

            <table
              v-for="(p, index) of bankData"
              class="table table-bordered"
              :key="`bank-` + index"
            >
              <colgroup>
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>用户名：</td>
                  <td>{{ p.bank_account || '-' }}</td>
                  <td>银行名称：</td>
                  <td colspan="2">{{ p.bank_name || '-' }}</td>
                  <td>银行账号：</td>
                  <td colspan="3">{{ p.bank_no || '-' }}</td>
                </tr>
                <tr>
                  <td colspan="2">日期</td>
                  <td colspan="2">收入</td>
                  <td colspan="2">支出</td>
                  <td colspan="3">备注</td>
                </tr>
                <tr v-for="(bank, j) of p.bankflow" :key="`bank-${index}-${j}`">
                  <td colspan="2">{{ bank.year }}</td>
                  <td colspan="2">{{ bank.income || '-' }}</td>
                  <td colspan="2">{{ bank.paid || '-' }}</td>
                  <td colspan="3">{{ bank.remark || '-' }}</td>
                </tr>
                <tr v-if="p.sumCol.hasVal" class="font-weight-bold">
                  <td colspan="2">合计</td>
                  <td colspan="2">{{ p.sumCol.income }}</td>
                  <td colspan="2">{{ p.sumCol.paid }}</td>
                  <td colspan="3"></td>
                </tr>
              </tbody>
            </table>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.bank_flow_des"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="银行流水备注"
                      rows="4"
                      type="text"
                      @blur="onReportSave('bank_flow_des')"
                    ></textarea>
                    <div v-else>{{ censusData.bank_flow_des || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">5、检验核实情况结论</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.finance_verify_result"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="检验核实情况结论"
                      rows="4"
                      type="text"
                      @blur="onReportSave('finance_verify_result')"
                    ></textarea>
                    <div v-else>{{ censusData.finance_verify_result || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- <table class="table table-bordered">
                <colgroup>
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                </colgroup>
                <tbody>
                  <tr>
                    <td rowspan="3">检验核实<br>情况</td>
                  </tr>
                  <tr>
                    <td colspan="9">现金流分析填写</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="9">
                      <textarea v-model="censusData.bank_flow_des"
                                class="form-control d-print-none"
                                id="form-5-2"
                                placeholder="说明"
                                rows="4"
                                type="text"
                                @blur="onReportSave('bank_flow_des')"></textarea>
                    </td>
                    <td v-else
                        colspan="9">
                      <div class="text-indent"
                           id="anchor-5-2">
                        <div v-anchor:report-edit.focus="'form-5-2'"
                             class="edit-eara">{{censusData.bank_flow_des || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table>
              <table class="table table-bordered">
                <colgroup>
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                </colgroup>
                <tbody>
                  <tr>
                    <td :rowspan="11">检验核实<br>情况</td>
                  </tr>
                  <tr>
                    <td colspan="9">3、用电分析（针对有独立电表的项目）</td>
                  </tr>
                  <tr>
                    <td colspan="9">
                      <chart-power-use :customer-related-id="customerRelatedId"
                                       :img-type="true"
                                       :width="760"></chart-power-use>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="9">用电分析（针对有独立电表的项目）</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="9">
                      <textarea v-model="censusData.ele_analysis_des"
                                class="form-control d-print-none"
                                id="form-5-3"
                                placeholder="用电分析："
                                rows="4"
                                type="text"
                                @blur="onReportSave('ele_analysis_des')"></textarea>
                    </td>
                    <td v-else
                        colspan="9">
                      <div class="text-indent"
                           id="anchor-5-3">
                        <div v-anchor:report-edit.focus="'form-5-3'"
                             class="edit-eara">{{censusData.ele_analysis_des || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table> -->
            <hr class="line" />
            <h3 class="report-section-title">六、融资性关键因素分析</h3>

            <h4 class="report-section-subtitle">1、借款原因及用途</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.borrowing_reason"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="借款原因及用途"
                      rows="4"
                      type="text"
                      @blur="onReportSave('borrowing_reason')"
                    ></textarea>
                    <div v-else>{{ censusData.borrowing_reason || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、还款计划及还款能力</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.repayment_plan"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="还款计划及还款能力"
                      rows="4"
                      type="text"
                      @blur="onReportSave('repayment_plan')"
                    ></textarea>
                    <div v-else>{{ censusData.repayment_plan || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr class="line" />
            <h3 class="report-section-title">七、反担保措施分析</h3>

            <h4 class="report-section-subtitle">1、反担保措施</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.counter_guarantee"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="反担保措施"
                      rows="4"
                      type="text"
                      @blur="onReportSave('counter_guarantee')"
                    ></textarea>
                    <div
                      v-else
                      class="text-left"
                      v-html="formatLine(censusData.counter_guarantee)"
                    ></div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、反担保措施评价</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.counter_guarantee_evaluation"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="反担保措施评价"
                      rows="4"
                      type="text"
                      @blur="onReportSave('counter_guarantee_evaluation')"
                    ></textarea>
                    <div
                      v-else
                      class="text-left"
                      v-html="formatLine(censusData.counter_guarantee_evaluation)"
                    ></div>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- <h3 align="center"
                  class="report-section-title">六、反担保分析</h3>
              <table class="table table-bordered">
                <colgroup>
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                  <col width="10%">
                </colgroup>
                <tbody>
                  <tr>
                    <td colspan="9">1、反担保措施及评价</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="9">
                      <textarea v-model="censusData.counter_guarantee_evaluation"
                                class="form-control d-print-none"
                                id="form-6-1"
                                placeholder="反担保措施评价"
                                rows="4"
                                type="text"
                                @blur="onReportSave('counter_guarantee_evaluation')"></textarea>
                    </td>
                    <td v-else
                        colspan="9">
                      <div class="text-indent"
                           id="anchor-6-1">
                        <div v-anchor:report-edit.focus="'form-6-1'"
                             class="edit-eara">{{censusData.counter_guarantee || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="9">2、反担保抵/质押物描述</td>
                  </tr>
                  <tr>
                    <td>保证类型</td>
                    <td colspan="2">单位/公司名称</td>
                    <td colspan="2">姓名/企业名称</td>
                    <td colspan="2">身份证/统一社会信用代码</td>
                    <td>收入(元)</td>
                    <td>备注</td>
                  </tr>
                  <tr v-for="(p, index) of warrantGuar"
                      :key="`pod-` + index">
                    <td>{{enumPledge[p.warrant_way]}}</td>
                    <td colspan="2">{{p.warrant_name}}</td>
                    <td colspan="2">{{p.warrant_own_name}}</td>
                    <td colspan="2">{{p.id_card}}</td>
                    <td>{{p.warrant_value}}</td>
                    <td>{{p.remark}}</td>
                  </tr>
                  <tr v-if="warrantGuar.length < 1">
                    <td colspan="9">暂无数据</td>
                  </tr>
                  <tr>
                    <td>质押类型</td>
                    <td colspan="2">质押物名称</td>
                    <td colspan="2">所有权姓名/企业名称</td>
                    <td colspan="2">身份证/统一社会信用代码</td>
                    <td>比例(%)</td>
                    <td>备注</td>
                  </tr>
                  <tr v-for="(p, index) of warrantPledge"
                      :key="`posd-` + index">
                    <td>{{enumZhiya[p.warrant_way]}}</td>
                    <td colspan="2">{{p.warrant_name}}</td>
                    <td colspan="2">{{p.warrant_own_name}}</td>
                    <td colspan="2">{{p.id_card}}</td>
                    <td>{{p.warrant_value}}</td>
                    <td>{{p.remark}}</td>
                  </tr>
                  <tr v-if="warrantGuar.length < 1">
                    <td colspan="9">暂无数据</td>
                  </tr>
                  <tr>
                    <td>抵押类型</td>
                    <td>抵押物名称</td>
                    <td>所有权姓名/企业名称</td>
                    <td>身份证/统一社会信用代码</td>
                    <td>抵押物面积/型号</td>
                    <td>抵押物原值/面值</td>
                    <td>估值(万元)</td>
                    <td>抵押率(%)</td>
                    <td>备注</td>
                  </tr>
                  <tr v-for="(p, index) of warrantMortgage"
                      :key="`mostd-` + index">
                    <td>{{enumDiya[p.warrant_way]}}</td>
                    <td>{{p.warrant_name}}</td>
                    <td>{{p.warrant_own_name}}</td>
                    <td>{{p.id_card}}</td>
                    <td>{{p.warrant_model}}</td>
                    <td>{{p.warrant_value}}</td>
                    <td>{{p.warrant_evalue}}</td>
                    <td>{{p.pledge_rate}}</td>
                    <td>{{p.remark}}</td>
                  </tr>
                  <tr v-if="warrantGuar.length < 1">
                    <td colspan="9">暂无数据</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="9">
                      <textarea v-model="censusData.counter_guarantee"
                                class="form-control d-print-none"
                                id="form-6-2"
                                placeholder="反担保措施"
                                rows="4"
                                type="text"
                                @blur="onReportSave('counter_guarantee')"></textarea>
                    </td>
                    <td v-else
                        colspan="9">
                      <div class="text-indent"
                           id="anchor-6-2">
                        <div v-anchor:report-edit.focus="'form-6-2'"
                             class="edit-eara">{{censusData.counter_guarantee || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table> -->
            <hr class="line" />
            <h3 class="report-section-title">八、项目优劣势及风险分析</h3>

            <h4 class="report-section-subtitle">1、优势方面</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.advantage_analysis"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="优势方面"
                      rows="4"
                      type="text"
                      @blur="onReportSave('advantage_analysis')"
                    ></textarea>
                    <div v-else>{{ censusData.advantage_analysis || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、劣势方面</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.disadvantage_analysis"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="劣势方面"
                      rows="4"
                      type="text"
                      @blur="onReportSave('disadvantage_analysis')"
                    ></textarea>
                    <div v-else>{{ censusData.disadvantage_analysis || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">3、项目风险分析</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.project_risk_analysis"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="项目风险分析"
                      rows="4"
                      type="text"
                      @blur="onReportSave('project_risk_analysis')"
                    ></textarea>
                    <div v-else>{{ censusData.project_risk_analysis || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- <table class="table table-bordered">
                <colgroup>
                  <col width="15%">
                  <col width="25%">
                  <col width="20%">
                  <col width="20%">
                  <col width="20%">
                </colgroup>
                <tbody>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="4">
                      <textarea v-model="censusData.advantage_analysis"
                                class="form-control d-print-none"
                                id="form-7-1"
                                placeholder="优势方面"
                                rows="4"
                                type="text"
                                @blur="onReportSave('advantage_analysis')"></textarea>
                    </td>
                    <td v-else
                        colspan="4">
                      <div class="text-indent"
                           id="anchor-7-1">
                        <div v-anchor:report-edit.focus="'form-7-1'"
                             class="edit-eara">{{censusData.advantage_analysis || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="4">2、劣势方面</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="4">
                      <textarea v-model="censusData.disadvantage_analysis"
                                class="form-control d-print-none"
                                id="form-7-2"
                                placeholder="劣势方面"
                                rows="4"
                                type="text"
                                @blur="onReportSave('disadvantage_analysis')"></textarea>
                    </td>
                    <td v-else
                        colspan="4">
                      <div class="text-indent"
                           id="anchor-7-2">
                        <div v-anchor:report-edit.focus="'form-7-2'"
                             class="edit-eara">{{censusData.disadvantage_analysis || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="4">3、项目风险分析</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="4">
                      <textarea v-model="censusData.project_risk_analysis"
                                class="form-control d-print-none"
                                id="form-7-3"
                                placeholder="项目风险分析"
                                rows="4"
                                type="text"
                                @blur="onReportSave('project_risk_analysis')"></textarea>
                    </td>
                    <td v-else
                        colspan="4">
                      <div class="text-indent"
                           id="anchor-7-3">
                        <div v-anchor:report-edit.focus="'form-7-3'"
                             class="edit-eara">{{censusData.project_risk_analysis || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="4">4、还款能力及还款计划</td>
                  </tr>
                  <tr>
                    <td v-if="!hasFinish"
                        colspan="4">
                      <textarea v-model="censusData.repayment_plan"
                                class="form-control d-print-none"
                                id="form-7-4"
                                placeholder="还款能力及还款计划"
                                rows="4"
                                type="text"
                                @blur="onReportSave('repayment_plan')"></textarea>
                    </td>
                    <td v-else
                        colspan="4">
                      <div class="text-indent"
                           id="anchor-7-4">
                        <div v-anchor:report-edit.focus="'form-7-4'"
                             class="edit-eara">{{censusData.repayment_plan || '-'}}
                        </div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table> -->
            <hr class="line" />
            <h3 class="report-section-title">九、调查结论及意见</h3>

            <h4 class="report-section-subtitle">1、调查报告意见</h4>

            <table class="table table-bordered">
              <tbody>
                <tr>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.census_opinion"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="调查报告意见"
                      rows="4"
                      type="text"
                      @blur="onReportSave('census_opinion')"
                    ></textarea>
                    <div v-else>{{ censusData.census_opinion || '-' }}</div>
                  </td>
                </tr>
              </tbody>
            </table>

            <h4 class="report-section-subtitle">2、相关人意见</h4>

            <table class="table table-bordered">
              <colgroup>
                <col width="10%" />
                <col width="90%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>调查员A角意见：</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.a_opinion"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="调查员A角意见"
                      rows="2"
                      type="text"
                      @blur="onReportSave('a_opinion')"
                    ></textarea>
                    <div v-else>{{ censusData.a_opinion || '-' }}</div>
                    <el-row :gutter="20">
                      <el-col :offset="1" :span="6">签字：</el-col>
                      <el-col :offset="6" :span="6">日期：</el-col>
                    </el-row>
                  </td>
                </tr>
                <tr>
                  <td>调查员B角意见：</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.b_opinion"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="调查员B角意见"
                      rows="2"
                      type="text"
                      @blur="onReportSave('b_opinion')"
                    ></textarea>
                    <div v-else>{{ censusData.b_opinion || '-' }}</div>
                    <el-row :gutter="20">
                      <el-col :offset="1" :span="6">签字：</el-col>
                      <el-col :offset="6" :span="6">日期：</el-col>
                    </el-row>
                  </td>
                </tr>
                <tr>
                  <td>风控人员意见：</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.risk_option"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="风控人员意见"
                      rows="2"
                      type="text"
                      @blur="onReportSave('risk_option')"
                    ></textarea>
                    <div v-else>{{ censusData.risk_option || '-' }}</div>
                    <el-row :gutter="20">
                      <el-col :offset="1" :span="6">签字：</el-col>
                      <el-col :offset="6" :span="6">日期：</el-col>
                    </el-row>
                  </td>
                </tr>
                <tr>
                  <td>有权审批人意见：</td>
                  <td class="report-input-td">
                    <textarea
                      v-model="censusData.approval_option"
                      class="form-control d-print-none"
                      v-if="!hasFinish"
                      placeholder="有权审批人意见"
                      rows="2"
                      type="text"
                      @blur="onReportSave('approval_option')"
                    ></textarea>
                    <div v-else>{{ censusData.approval_option || '-' }}</div>
                    <el-row :gutter="20">
                      <el-col :offset="1" :span="6">签字：</el-col>
                      <el-col :offset="6" :span="6">日期：</el-col>
                    </el-row>
                  </td>
                </tr>
              </tbody>
            </table>

            <div style="page-break-after: always">
              <h3 class="report-section-title">附件</h3>

              <div v-if="!hasFinish" class="d-print-none">
                <upload-oss
                  multiple
                  accept="image/*"
                  listType="picture-card"
                  :limit="4"
                  :file-list="attachFileListOne"
                  :on-complete="handleImagesCompleteOne"
                  :on-exceed="handleOnExceed"
                  :on-remove="handleRemove"
                  auto-upload
                  ref="attachOssOne"
                ></upload-oss>
              </div>

              <div class="d-none d-print-block">
                <div
                  v-for="(img, index) in attachFileListOne"
                  :key="index"
                  class="mb-1 text-center"
                >
                  <img :src="img.url" alt="附件图片" height="400" style="max-width: 100%" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="my-1">
      <el-button
        plain
        size="small"
        type="primary"
        v-if="!hasFinish"
        v-show="!viewMode"
        @click="onFinishCencus"
      >
        <i class="fa fa-check-circle"></i>
        完成报告
      </el-button>

      <el-button plain size="small" type="primary" @click="onPrint">
        <i class="fa fa-print"></i>
        打印
      </el-button>
    </div>
  </div>
</template>
<script>
import {
  enumAssetsType,
  enumCorpType,
  enumDiya,
  enumEduType,
  enumEleUseType,
  enumFarmType,
  enumMarrType,
  enumOwnSit,
  enumPledge,
  enumSexType,
  enumTypeer,
  enumWarrantType,
  enumWarrantWayType,
  enumZhiya,
} from '@/credit/plugins/enum'
import { formatLine } from '@/common/plugins/tools/format'
import { printHtml, arrayFromString } from '@vimi/utils-tool'

// import ChartPowerUse from '@/credit/components/chart/ChartPowerUse'
import SelectStaffper from '@/credit/components/select/SelectStaffper'
import SelectBank from '@/credit/components/select/SelectBankId'

const CREDIT_SERVER = 'credit'
const yearNow = new Date().getFullYear()

export default {
  components: {
    // ChartPowerUse,
    SelectStaffper,
    SelectBank,
  },
  props: {
    viewMode: Boolean,
    relatedId: String,
  },
  data() {
    return {
      enumSexType,
      enumEduType,
      enumFarmType,
      enumEleUseType,
      enumCorpType,
      enumMarrType,
      enumTypeer,
      enumAssetsType,
      enumOwnSit,
      enumWarrantWayType,
      enumWarrantType,
      enumZhiya,
      enumDiya,
      enumPledge,
      apiError: false,
      // 项目基本信息
      relatedData: {},
      // 报告
      censusData: {},
      reportData: {},
      // 银行
      // bankenumData: {},
      // 企业法人情况
      comRateData: [],
      shareholderData: {},
      // 企业基本情况
      infoData: {},
      // 实际控制人姓名
      controllerName: '',
      // 用工情况
      employmentData: {},
      // 征信
      topData: [],
      datalength: 0,

      // 银行卡信息
      Carddata: [],
      cardData: {},
      carData: {},
      // 申请人对外担保情况
      Foreign: [],
      // 人员信息
      dataInfoSh: [], // 股东信息（包括法人与配偶）
      dataCorpSh: [], // 股东信息（不包括法人）
      dataShTree: {}, // 每个人员的贷款信息，包括贷款信息、历史结清贷款情况
      // 个人/公司财产
      assetsData: [],
      // 主要供货商
      gongData: [],
      gongAll: 0,
      // 销售商信息
      xiaodata: [],
      xiaoAll: 0,
      // 财务情况
      financeTable: [],
      // 利润表
      incomeStatement: [],
      financePoint: [],
      normdata: {},
      // 资金来源明细
      sourcesData: [],
      // 固定投入情况
      twoData: [],
      twoAmount: 0,
      // 流动情况
      threeData: [],
      threeAmount: 0,
      // 客户信息核实
      postVdata: {},
      vdata: {},
      // 现金流分析
      bankData: [],
      // 反担保抵/质押物描述
      warrantData: [],
      warrantGuar: [],
      warrantPledge: [],
      warrantMortgage: [],
      // myou
      id: '',
      customerRelatedId: this.relatedId,
      // 尽调报告
      censusId: '',
      dataCensus: {},
      // 附件图片最多两张  一张A4纸显示
      attachFileListOne: [],
      // 反担保方式
      dataLevelReview: {},
      dataLevelReviewSolid: {},

      // 编号
      censusNumberPrefix: 'TDC',
      censusNumberYear: '',
      censusNumberSerial: '',

      // 保存
      focusFromReport: false,
      saveLoading: false,
    }
  },
  computed: {
    hasFinish() {
      return this.censusData.census_status === '2' || this.viewMode
    },
    clientId() {
      return this.$store.getters.org.clientId
    },
  },
  watch: {
    relatedId() {
      this.init()
    },
  },
  created() {
    this.init()
  },
  mounted() {},
  methods: {
    formatLine,
    init() {
      this.id = this.customerRelatedId =
        this.relatedId || this.$route.query.id || sessionStorage.getItem('customer_related_id')
      if (!this.customerRelatedId) {
        return false
      }
      this.dataCensus.customer_related_id = this.customerRelatedId
      this.getData()
    },

    // 客户及关联信息
    getData() {
      this.getRelatedData()
      this.getBankData()
      this.getCensusData()
      // this.getShareholderData()
      this.getInfoData()
      this.getPersonnelData()
      this.getForeignData()
      this.getDataBaseSh()
      this.getGSata()
      this.getFinanceData()
      this.getIncomeStatement()
      this.getTData()
      this.getsourcesData()
      this.getProjectData()
      this.getVData()

      this.getDataBase()
      this.getCensusReport()
      this.getLevelReview()
      this.getCardData()
      // this.getTopData()
      // this.getBankenumData()
    },
    // getBankenumData() {
    //   this.$api.getData('credit', 'bank_enum', {
    //     'bank_code.eq': this.id
    //   }).then(res => {
    //     this.bankenumData = (res && res.data && res.data.length && res.data[0]) || {}
    //   })
    // },
    // 关联基本信息
    async getDataBase() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'customer_related_base_view', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.dataBase = (res && res.data && res.data.length && res.data[0]) || {}
      this.dataCensus.customer_id = this.dataBase.customer_id || ''
    },
    // 尽调报告
    async getCensusReport() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'credit_census_report', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.dataCensus = (res && res.data && res.data.length && res.data[0]) || {}
      this.censusId = this.dataCensus.id || ''
    },
    getGuarantData() {
      this.$api
        .getData('credit', 'datum_customer_warrant', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.warrantData = (res && res.data) || []
          this.warrantGuar = []
          this.warrantPledge = []
          this.warrantMortgage = []
          for (let p of this.warrantData) {
            if (p.warrant_type === '1') {
              this.warrantGuar.push(p)
            } else if (p.warrant_type === '2') {
              this.warrantPledge.push(p)
            } else {
              this.warrantMortgage.push(p)
            }
          }

          // 反担保措施从数据收集的列表同步过来 @20190305
          if (
            (this.censusData.counter_guarantee === null ||
              this.censusData.counter_guarantee === undefined) &&
            this.warrantData.length
          ) {
            let str = ''
            let index = 1
            for (let p of this.warrantGuar) {
              str += `(${index})、${p.warrant_name || '-'}签订反担保合同，承担连带责任。\n`
              index++
            }
            for (let p of this.warrantPledge) {
              str += `(${index})、${p.warrant_own_name || '-'}提供所持有${
                p.warrant_name || '-'
              }公司的${p.warrant_value || '-'}%股权作质押反担保，办理股权质押登记。\n`
              index++
            }
            for (let p of this.warrantMortgage) {
              str += `(${index})、${p.warrant_own_name || '-'}提供所有位于${
                p.address || '-'
              }，面积${p.warrant_model || '-'}，房产/土地证号：${
                p.id_card || '-'
              }的房产/土地作抵押反担保，办理抵押登记。\n`
              index++
            }

            this.censusData.counter_guarantee = str
            this.onReportSave('counter_guarantee')
          }
        })
    },

    getBankData() {
      this.$api
        .getData('credit', 'datum_customer_finance_bank_account', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          const ids = []
          this.bankData = ((res && res.data) || []).map(item => {
            ids.push(item.datum_customer_finance_bank_account_id)
            item.bankflow = []
            item.sumCol = {
              hasVal: false,
              income: 0,
              paid: 0,
            }
            return item
          })
          if (this.bankData.length) {
            this.getBankDetailData(ids.join(','))
          }
        })
    },

    getBankDetailData(ids) {
      this.$api
        .getData(
          'credit',
          'datum_customer_finance_bank',
          {
            'datum_customer_finance_bank_account_id.in': ids,
          },
          { year: 'asc', month: 'asc' }
        )
        .then(res => {
          if (res) {
            let data = res.data || []
            for (let d of this.bankData) {
              d.bankflow = []
              let income = 0
              let paid = 0
              for (let i = data.length - 1; i >= 0; i--) {
                let we = { ...data[i] }
                if (
                  we.datum_customer_finance_bank_account_id ===
                  d.datum_customer_finance_bank_account_id
                ) {
                  d.bankflow.push(we)

                  d.sumCol.hasVal = true
                  income += Number.parseFloat(we.income) || 0
                  paid += Number.parseFloat(we.paid) || 0

                  data.splice(i, 1)
                }
              }

              d.sumCol.income = income.toFixed(2)
              d.sumCol.paid = paid.toFixed(2)
            }
          }
        })
    },

    getVData() {
      this.$api
        .getData('credit', 'datum_customer_info_verify', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.postVdata = (res && res.data && res.data.length && res.data[0]) || {}
          this.vdata = { ...this.postVdata }
        })
    },
    getsourcesData() {
      this.sourcesData = []
      this.$api
        .getData('credit', 'datum_customer_finance_capital_source', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.sourcesData = (res && res.data) || []
        })
    },
    getProjectData() {
      this.twoAmount = 0
      this.threeAmount = 0
      this.twoData = []
      this.threeData = []
      this.$api
        .getData('credit', 'datum_customer_finance_project_input', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          if (res && res.data) {
            let solidTotal = 0
            let flowTotal = 0
            for (const d of res.data) {
              const t = Number.parseFloat(d.funds)
              const o = isNaN(t) ? 0 : t
              if (d.input_type === '1') {
                this.twoData.push(d)
                solidTotal += o
              } else {
                this.threeData.push(d)
                flowTotal += o
              }
            }
            this.twoAmount = Math.round(solidTotal * 100) / 100
            this.threeAmount = Math.round(flowTotal * 100) / 100
          }
        })
    },
    getTData() {
      this.$api
        .getData('credit', 'datum_customer_finance_norm', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.normdata = (res && res.data && res.data.length && res.data[0]) || {}
        })
    },

    getFix: (num, len = 2) => Math.round(num * Math.pow(10, len)) / Math.pow(10, len),

    getNum: num => Number.parseFloat(num) || 0,

    getUnit: (num, unit) => (num ? `${num}${unit}` : ''),

    getFinanceData() {
      this.$api
        .getData(
          'credit',
          'datum_customer_finance_report',
          {
            'customer_related_id.eq': this.id,
          },
          { report_date: 'desc' }
        )
        .then(res => {
          const data = (res && res.data) || []
          this.financeTable = []
          if (data.length < 4) {
            return
          }

          let calcIndex = 0
          const sumArray = [
            [0, 0, 0, 0, 0, 0], // 流动资产小计
            [0, 0, 0, 0, 0, 0], // 固定资产小计
            [0, 0, 0, 0, 0, 0], // 负债小计
            [0, 0, 0, 0, 0, 0], // 权益小计
          ]

          const getCha = (data1, data2) => Math.round((data2 - data1) * 100) / 100
          const getRow = (col1 = '', key = '') => {
            const col2 = this.getNum(data[0][key])
            const col3 = this.getNum(data[1][key])
            const col4 = this.getNum(data[2][key])
            const col6 = this.getNum(data[3][key])
            const col5 = getCha(col4, col3)
            const col7 = getCha(col6, col4)

            // 计算小计
            sumArray[calcIndex][0] += col2
            sumArray[calcIndex][1] += col3
            sumArray[calcIndex][2] += col4
            sumArray[calcIndex][3] += col5
            sumArray[calcIndex][4] += col6
            sumArray[calcIndex][5] += col7

            return { col1, col2, col3, col4, col5, col6, col7 }
          }
          const pushTable = arr => {
            for (let item of arr) {
              this.financeTable.push(getRow(item.label, item.key))
            }
          }
          const pushSumRow = col1 => {
            this.financeTable.push({
              col1,
              col2: sumArray[calcIndex][0],
              col3: sumArray[calcIndex][1],
              col4: sumArray[calcIndex][2],
              col5: sumArray[calcIndex][3],
              col6: sumArray[calcIndex][4],
              col7: sumArray[calcIndex][5],
              css: 'font-weight-bold',
            })
          }
          const pushAddRow = (col1, rowIndex1, rowIndex2) => {
            this.financeTable.push({
              col1,
              col2: sumArray[rowIndex1][0] + sumArray[rowIndex2][0],
              col3: sumArray[rowIndex1][1] + sumArray[rowIndex2][1],
              col4: sumArray[rowIndex1][2] + sumArray[rowIndex2][2],
              col5: sumArray[rowIndex1][3] + sumArray[rowIndex2][3],
              col6: sumArray[rowIndex1][4] + sumArray[rowIndex2][4],
              col7: sumArray[rowIndex1][5] + sumArray[rowIndex2][5],
              css: 'font-weight-bold',
            })
          }

          // 表头
          this.financeTable.push({
            col1: '',
            col2: this.$utils.dateFormat(data[0].report_date, 'yyyy年M月'),
            col3: this.getUnit(data[1].report_date, '年'),
            col4: this.getUnit(data[2].report_date, '年'),
            col5: '变动额',
            col6: this.getUnit(data[3].report_date, '年'),
            col7: '变动额',
          })

          // 流动资产
          calcIndex = 0
          pushTable([
            { label: '货币资金', key: 'currency' },
            { label: '应收账款', key: 'receivables' },
            { label: '预付账款', key: 'pre_charge' },
            { label: '存货', key: 'stock' },
            { label: '其他应收款', key: 'other_receivables' },
            { label: '其他流动资产', key: 'other_current_assets' },
          ])
          pushSumRow('流动资产小计')

          // 固定资产
          calcIndex = 1
          pushTable([
            { label: '长期投资', key: 'long_invest' },
            { label: '固定资产净额', key: 'net_fixed_assets' },
            { label: '在建工程', key: 'const_project' },
            { label: '无形资产净额', key: 'net_intangible_assets' },
          ])
          pushSumRow('固定资产小计')
          pushAddRow('资产合计', 0, 1)

          // 负债
          calcIndex = 2
          pushTable([
            { label: '短期借款', key: 'short_load' },
            { label: '应付账款', key: 'should_charge' },
            { label: '预收账款', key: 'pre_receivables' },
            { label: '其他应付款', key: 'other_should_charge' },
            { label: '其他流动负债', key: 'other_current_debt' },
            { label: '长期负债', key: 'long_debt' },
          ])
          pushSumRow('负债小计')

          // 权益
          calcIndex = 3
          pushTable([
            { label: '实收资本或股本', key: 'paid_capital' },
            { label: '资本公积', key: 'capital_reserve' },
            { label: '留存收益', key: 'retained_earnings' },
            { label: '未分配利润', key: 'und_profit' },
          ])
          pushSumRow('权益小计')
          pushAddRow('负债与所有者权益合计', 2, 3)

          this.getFinancePoint()
        })
    },

    async getIncomeStatement() {
      const [res] = await this.$utils.promise(
        this.$api.getData(
          'credit',
          'datum_customer_finance_report_profit',
          {
            'customer_related_id.eq': this.id,
          },
          { report_date: 'desc' }
        )
      )
      let data = (res && res.data) || []
      this.incomeStatement = []

      if (data.length < 4) {
        return
      }

      // key -> col
      const getCha = (data1, data2) => Math.round((data2 - data1) * 100) / 100
      const getRow = (col1 = '', key = '') => {
        const col2 = this.getNum(data[0][key])
        const col3 = this.getNum(data[1][key])
        const col4 = this.getNum(data[2][key])
        const col6 = this.getNum(data[3][key])
        const col5 = getCha(col4, col3)
        const col7 = getCha(col6, col4)
        return { col1, col2, col3, col4, col5, col6, col7, key }
      }
      const pushTable = arr => {
        for (let item of arr) {
          this.incomeStatement.push(getRow(item.label, item.key))
        }
      }

      // 表头
      this.incomeStatement.push({
        col1: '',
        col2: this.$utils.dateFormat(data[0].report_date, 'yyyy年M月'),
        col3: this.getUnit(data[1].report_date, '年'),
        col4: this.getUnit(data[2].report_date, '年'),
        col5: '变动额',
        col6: this.getUnit(data[3].report_date, '年'),
        col7: '变动额',
      })

      // 主营业务利润
      pushTable([
        { label: '主营业务收入', key: 'main_business_income' },
        { label: '主营业务成本', key: 'main_business_cost' },
        { label: '税金及附加', key: 'taxes_surcharges' },
      ])
      const getMainBusSum = key =>
        this.getFix(
          this.incomeStatement[1][key] - this.incomeStatement[2][key] - this.incomeStatement[3][key]
        )
      this.incomeStatement.push({
        col1: '主营业务利润',
        col2: getMainBusSum('col2'),
        col3: getMainBusSum('col3'),
        col4: getMainBusSum('col4'),
        col5: getMainBusSum('col5'),
        col6: getMainBusSum('col6'),
        col7: getMainBusSum('col7'),
        css: 'font-weight-bold',
      })

      // 营业利润
      pushTable([
        { label: '营业费用', key: 'business_fee' },
        { label: '管理费用', key: 'manage_fee' },
        { label: '财务费用', key: 'finance_fee' },
      ])
      const getOperateProfitSum = key =>
        this.getFix(
          this.incomeStatement[4][key] -
            this.incomeStatement[5][key] -
            this.incomeStatement[6][key] -
            this.incomeStatement[7][key]
        )
      this.incomeStatement.push({
        col1: '营业利润',
        col2: getOperateProfitSum('col2'),
        col3: getOperateProfitSum('col3'),
        col4: getOperateProfitSum('col4'),
        col5: getOperateProfitSum('col5'),
        col6: getOperateProfitSum('col6'),
        col7: getOperateProfitSum('col7'),
        css: 'font-weight-bold',
      })

      pushTable([
        { label: '营业外收入', key: 'busi_out_income' },
        { label: '营业外支出', key: 'busi_out_pay' },
      ])
      const getAllProfitSum = key =>
        this.getFix(
          this.incomeStatement[8][key] +
            this.incomeStatement[9][key] -
            this.incomeStatement[10][key]
        )
      this.incomeStatement.push({
        col1: '利润总额',
        col2: getAllProfitSum('col2'),
        col3: getAllProfitSum('col3'),
        col4: getAllProfitSum('col4'),
        col5: getAllProfitSum('col5'),
        col6: getAllProfitSum('col6'),
        col7: getAllProfitSum('col7'),
        css: 'font-weight-bold',
      })

      pushTable([{ label: '所得税', key: 'income_tax' }])
      const getPureProfitSum = key =>
        this.getFix(this.incomeStatement[11][key] - this.incomeStatement[12][key])
      this.incomeStatement.push({
        col1: '净利润',
        col2: getPureProfitSum('col2'),
        col3: getPureProfitSum('col3'),
        col4: getPureProfitSum('col4'),
        col5: getPureProfitSum('col5'),
        col6: getPureProfitSum('col6'),
        col7: getPureProfitSum('col7'),
        css: 'font-weight-bold',
      })

      this.getFinancePoint()
    },

    getFinancePoint() {
      this.financePoint = []
      if (this.financeTable.length < 27 || this.incomeStatement.length < 14) {
        return
      }

      const getRate = (top, bottom, hasSymbol = false) =>
        bottom === 0
          ? ''
          : `${this.getFix((top * (hasSymbol ? 100 : 1)) / bottom, 4)}${hasSymbol ? '%' : ''}`

      this.financePoint.push({
        col1: '',
        col2: this.incomeStatement[0].col2,
        col3: this.incomeStatement[0].col3,
        col4: this.incomeStatement[0].col4,
        col5: '变动额',
        col6: this.incomeStatement[0].col6,
        col7: '变动额',
      })

      this.financePoint.push({ col1: '短期偿债能力指标：', css: 'font-weight-bold' })
      this.financePoint.push({
        col1: '流动比率：',
        col3: getRate(this.financeTable[7].col3, this.financeTable[20].col3),
        col4: getRate(this.financeTable[7].col4, this.financeTable[20].col4),
      })
      this.financePoint.push({
        col1: '流动比率：',
        col3: getRate(
          this.financeTable[7].col3 - this.financeTable[4].col3,
          this.financeTable[20].col3
        ),
        col4: getRate(
          this.financeTable[7].col4 - this.financeTable[4].col4,
          this.financeTable[20].col4
        ),
      })
      this.financePoint.push({
        col1: '流动比率：',
        col3: getRate(this.financeTable[1].col3, this.financeTable[20].col3),
        col4: getRate(this.financeTable[1].col4, this.financeTable[20].col4),
      })

      this.financePoint.push({ col1: '长期偿债能力指标：', css: 'font-weight-bold' })
      this.financePoint.push({
        col1: '负债比率：',
        col2: getRate(
          this.financeTable[26].col2 - this.financeTable[25].col2,
          this.financeTable[13].col2
        ),
        col3: getRate(
          this.financeTable[26].col3 - this.financeTable[25].col3,
          this.financeTable[13].col3
        ),
        col4: getRate(
          this.financeTable[26].col4 - this.financeTable[25].col4,
          this.financeTable[13].col4
        ),
        col6: getRate(
          this.financeTable[26].col6 - this.financeTable[25].col6,
          this.financeTable[13].col6
        ),
      })

      this.financePoint.push({ col1: '资金周转指标：', css: 'font-weight-bold' })
      this.financePoint.push({
        col1: '存货周转率：',
        col2: getRate(this.incomeStatement[2].col2, this.financeTable[4].col2),
        col3: getRate(this.incomeStatement[2].col3, this.financeTable[4].col3),
        col4: getRate(this.incomeStatement[2].col4, this.financeTable[4].col4),
        col6: getRate(this.incomeStatement[2].col6, this.financeTable[4].col6),
      })
      this.financePoint.push({
        col1: '应收账款周转率：',
        col2: getRate(this.incomeStatement[1].col2, this.financeTable[2].col2),
        col3: getRate(this.incomeStatement[1].col3, this.financeTable[2].col3),
        col4: getRate(this.incomeStatement[1].col4, this.financeTable[2].col4),
        col6: getRate(this.incomeStatement[1].col6, this.financeTable[2].col6),
      })
      this.financePoint.push({
        col1: '总资产周转率：',
        col2: getRate(this.incomeStatement[1].col2, this.financeTable[13].col2),
        col3: getRate(this.incomeStatement[1].col3, this.financeTable[13].col3),
        col4: getRate(this.incomeStatement[1].col4, this.financeTable[13].col4),
        col6: getRate(this.incomeStatement[1].col6, this.financeTable[13].col6),
      })

      this.financePoint.push({ col1: '盈利能力指标', css: 'font-weight-bold' })
      this.financePoint.push({
        col1: '销售利润率：',
        col2: getRate(this.incomeStatement[4].col2, this.incomeStatement[1].col2, true),
        col3: getRate(this.incomeStatement[4].col3, this.incomeStatement[1].col3, true),
        col4: getRate(this.incomeStatement[4].col4, this.incomeStatement[1].col4, true),
        col6: getRate(this.incomeStatement[4].col6, this.incomeStatement[1].col6, true),
      })
      this.financePoint.push({
        col1: '资产收益率：',
        col2: getRate(this.incomeStatement[1].col2, this.financeTable[13].col2, true),
        col3: getRate(this.incomeStatement[1].col3, this.financeTable[13].col3, true),
        col4: getRate(this.incomeStatement[1].col4, this.financeTable[13].col4, true),
        col6: getRate(this.incomeStatement[1].col6, this.financeTable[13].col6, true),
      })
      this.financePoint.push({
        col1: '权益收益率：',
        col2: getRate(this.incomeStatement[1].col2, this.financeTable[25].col2, true),
        col3: getRate(this.incomeStatement[1].col3, this.financeTable[25].col3, true),
        col4: getRate(this.incomeStatement[1].col4, this.financeTable[25].col4, true),
        col6: getRate(this.incomeStatement[1].col6, this.financeTable[25].col6, true),
      })
    },

    getGSata() {
      this.gongData = []
      this.xiaodata = []
      this.gongAll = 0
      this.xiaoAll = 0
      this.$api
        .getData('credit', 'datum_customer_business_sm', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          const data = (res && res.data) || []

          let gongTotal = 0
          let xiaoTotal = 0
          for (const d of data) {
            const t = Number.parseFloat(d.sm_total)
            const o = isNaN(t) ? 0 : t
            if (d.sm_type === '1') {
              this.gongData.push(d)
              gongTotal += o
            } else {
              this.xiaodata.push(d)
              xiaoTotal += o
            }
          }
          this.gongAll = Math.round(gongTotal * 10000) / 10000
          this.xiaoAll = Math.round(xiaoTotal * 10000) / 10000
        })
    },

    getDataBaseSh() {
      this.$api
        .getData('credit', 'datum_customer_shareholder', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.dataInfoSh = ((res && res.data) || []).map(item => {
            item.spouseInfo = {}
            return item
          })
          for (let rd of this.dataInfoSh) {
            rd.handEdu = []
            rd.workExp = []
          }
          this.getWorkExp()
          this.getTopData()
        })
    },

    getWorkExp() {
      this.$api
        .getData(
          'credit',
          'datum_customer_work_exp',
          {
            'customer_related_id.eq': this.id,
          },
          { age_inter: 'asc' }
        )
        .then(res => {
          let data = (res && res.data) || []

          // 给每个员工添加工作经历
          for (const d of this.dataInfoSh) {
            d.workExp = []
            for (let i = 0; i < data.length; i++) {
              let we = data[i]
              if (we.datum_customer_shareholder_id === d.datum_customer_shareholder_id) {
                we.datePeriod = `${we.start_date}~${we.end_date}`
                d.workExp.push(we)
                // data.splice(i, 1)
              }
            }
            if (!d.workExp.length) {
              d.workExp.push({
                datePeriod: '-',
                age_inter: '-',
                customer_name: '-',
                work_unit: '-',
                end_date: '-',
                assets_total: '-',
                remark: '-',
                start_date: '-',
              })
            }
          }

          this.getHandEducation()
        })
    },

    getHandEducation() {
      this.$api
        .getData(
          'credit',
          'datum_customer_hand_education',
          {
            'customer_related_id.eq': this.id,
          },
          { age_inter: 'asc' }
        )
        .then(res => {
          let data = (res && res.data) || []

          // 给每个员工添加受教育情况
          this.dataCorpSh = []
          for (let d of this.dataInfoSh) {
            d.handEdu = []
            for (let i = 0; i < data.length; i++) {
              let he = data[i]
              if (he.datum_customer_shareholder_id === d.datum_customer_shareholder_id) {
                he.datePeriod = `${he.start_date}~${he.end_date}`
                d.handEdu.push({ ...he })
                // data.splice(i, 1)
              }
            }
            if (!d.handEdu.length) {
              d.handEdu.push({
                datePeriod: '-',
                age_inter: '-',
                customer_name: '-',
                education_mech: '-',
                end_date: '-',
                profession: '-',
                remark: '-',
                start_date: '-',
              })
            }
          }

          this.getAssetsData()
        })
    },

    getAssetsData() {
      this.$api
        .getData('credit', 'datum_customer_assets', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.assetsData = (res && res.data) || []

          // （2、股东及配偶简历）不包括法人
          const tempRateData = []
          const data = [...this.dataInfoSh]
          for (const d of this.dataInfoSh) {
            // 配偶信息
            for (let i = 0; i < data.length; i++) {
              let he = data[i]
              // 为了获取配偶的联系电话、身份证地址、工作/经营年限，循环自身来匹配，我也是拼了！
              if (d.spouse_related_id === he.datum_customer_shareholder_id) {
                this.$set(d, 'spouseInfo', { ...he })
                data.splice(i, 1)
              }
            }

            // 排除法人及法人配偶 (1 法人 2 法人配偶 3 股东（自然人） 4股东（企业） 5 非股东 6 股东配偶)
            if (['1', '2'].indexOf(d.is_corp) === -1 && Number.parseFloat(d.sh_rate) > 0) {
              this.dataCorpSh.push({ ...d })
            }

            // 实际控制人
            if (d.is_actual_controller === '1') {
              this.controllerName = d.real_name
            }

            // 法人
            if (d.is_corp === '1') {
              this.shareholderData = d
            } else if (+d.sh_rate > 0) {
              // 股东花名册，排除法人
              tempRateData.push(d)
            }
          }

          // 按照股权比例高低做调整（有高到低，降序排列）简历同步排列方式
          tempRateData.sort((a, b) => b.sh_rate - a.sh_rate)
          this.comRateData = tempRateData
        })
    },

    getForeignData() {
      this.$api
        .getData('credit', 'datum_customer_warrant_foreign', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.Foreign = (res && res.data) || []
          if (!this.Foreign.length) {
            this.Foreign.push({
              warrant_object: '-',
              warrant_period: '-',
              warrant_funds: '-',
              warrant_left_funds: '-',
              remark: '-',
            })
          }
        })
    },

    // 用工情况信息
    getPersonnelData() {
      this.$api
        .getData('credit', 'datum_customer_emp', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.employmentData = (res && res.data && res.data.length && res.data[0]) || {}
        })
    },

    getInfoData() {
      this.$api
        .getData('credit', 'datum_customer_info', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.infoData = (res && res.data && res.data.length && res.data[0]) || {}
        })
    },

    // api速度很慢
    // getShareholderData() {
    //   this.$api.getData('credit', 'datum_customer_shareholder_view', {
    //     'customer_related_id.eq': this.id
    //   }).then(res => {
    //     this.shareholderData = {}
    //     const data = (res && res.data) || []

    //     const tempRateData = []
    //     for (let p of data) {
    //       if (p.is_actual_controller === '1') {
    //         this.controllerName = p.real_name
    //       }
    //       if (p.is_corp === '1') {
    //         this.shareholderData = p
    //       } else if (+p.sh_rate > 0) {
    //         // 股东花名册，排除法人
    //         tempRateData.push(p)
    //       }
    //     }

    //     // 按照股权比例高低做调整（有高到低，降序排列）简历同步排列方式
    //     tempRateData.sort((a, b) => b.sh_rate - a.sh_rate)
    //     this.comRateData = tempRateData
    //   }).then(() => {
    //     this.getCardData()
    //   })
    // },

    getCardData() {
      this.$api
        .getData('credit', 'datum_customer_credit', {
          'customer_related_id.eq': this.id,
          'credit_type.eq': '2',
        })
        .then(res => {
          this.Carddata = (res && res.data) || []
          this.cardData = (res && res.data && res.data.length && res.data[0]) || {}
          this.carData = { ...this.cardData }
        })
    },

    async getTopData() {
      const [res] = await this.$utils.promise(
        this.$api.getData(
          'credit',
          'datum_customer_credit',
          {
            'customer_related_id.eq': this.id,
            'credit_type.eq': '1',
          },
          { shareholder_name: 'desc' }
        )
      )
      const data = (res && res.data) || []

      const dataTree = {}
      for (let d of data) {
        const temp = dataTree[d.datum_customer_shareholder_id]
        if (temp) {
          temp.loan.push(d)
        } else {
          dataTree[d.datum_customer_shareholder_id] = { loan: [d], overdue: {} }
        }
      }

      this.dataShTree = {}
      for (let d of this.dataInfoSh) {
        const t = dataTree[d.datum_customer_shareholder_id] || { loan: [], overdue: {} }
        t.data = d
        this.dataShTree[d.datum_customer_shareholder_id] = t
      }

      this.getCreditReturn()
    },

    async getCreditReturn() {
      const [res] = await this.$utils.promise(
        this.$api.getData('credit', 'datum_customer_credit_return', {
          'customer_related_id.eq': this.id,
        })
      )
      const data = (res && res.data) || []

      const crTree = {}
      for (let ct of data) {
        crTree[ct.datum_customer_shareholder_id] = ct
      }

      this.topData = []
      for (let key in this.dataShTree) {
        let fundsSum = 0
        let leftSum = 0
        let index = 0

        // 历史结清贷款情况
        const ctData = crTree[key]
        const loan = this.dataShTree[key].loan
        const shData = this.dataShTree[key].data
        const count = loan.length

        if (!count && !ctData) {
          continue
        }

        let id = ''
        let remark = ''

        for (let temp of loan) {
          fundsSum += Number.parseFloat(temp.loan_funds) || 0
          leftSum += Number.parseFloat(temp.loan_left) || 0
          temp.rowspan = index === 0 ? count + (ctData ? 3 : 1) : 0
          this.topData.push(temp)
          id = temp.id
          remark = temp.remark
          index++
        }

        if (count) {
          this.topData.push({
            creditType: 1,
            loan_bank: '小计',
            creditCount: count,
            leftSum: leftSum.toFixed(2),
            fundsSum: fundsSum.toFixed(2),
          })
        } else {
          this.topData.push({
            rowspan: ctData ? 3 : 1,
            shareholder_name: shData.real_name,
            loan_bank: '-',
          })
        }

        if (ctData) {
          this.topData.push({
            creditType: 3,
            load_num: '历史结清贷款笔数',
            return_funds: '历史结清总金额',
            overdue_num: '历史结清逾期次数',
            overdue_max_funds: '历史结清贷款最高逾期金额及逾期时间',
            overdue_max_months: '历史结清贷款最长逾期时间及金额',
          })
          this.topData.push({
            creditType: 4,
            load_num: ctData.load_num,
            return_funds: ctData.return_funds,
            overdue_num: ctData.overdue_num,
            overdue_max_funds: ctData.overdue_max_funds,
            overdue_max_funds_months: ctData.overdue_max_funds_months,
            overdue_max_months: ctData.overdue_max_months,
            overdue_max_months_months: ctData.overdue_max_months_months,
          })
        }

        this.topData.push({
          creditType: 2,
          remark,
          id,
        })
      }
    },

    getCensusData() {
      this.censusNumberYear = ''
      this.censusNumberSerial = ''

      this.$api
        .getData('credit', 'credit_census_report', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          this.censusData = (res && res.data && res.data.length && res.data[0]) || {}
          this.reportData = { ...this.censusData }

          this.attachFileListOne = arrayFromString(this.censusData.attachment).map(item => {
            return { name: '', url: item }
          })

          // 编号
          if (this.censusData.census_number) {
            const arr = this.censusData.census_number.split('-')
            if (arr.length > 2) {
              this.censusNumberYear = arr[1]
              this.censusNumberSerial = arr[2]
            }
          }

          this.apiError = false
          this.getGuarantData()
        })
        .catch(() => {
          this.apiError = true
        })
    },

    async getLevelReview() {
      const [res] = await this.$utils.promise(
        this.$api.getData('credit', 'credit_level_review', { 'customer_related_id.eq': this.id })
      )
      this.dataLevelReview = (res && res.data && res.data.length && res.data[0]) || {}
      this.dataLevelReviewSolid = { ...this.dataLevelReview }
    },

    async onLevelReviewSave(key) {
      const data = {}
      if (
        !this.dataLevelReviewSolid[key] ||
        this.dataLevelReview[key] !== this.dataLevelReviewSolid[key]
      ) {
        data[key] = this.dataLevelReview[key]
        if (this.dataLevelReview.id) {
          let [res, err] = await this.$utils.promise(
            this.$api.updateData('credit', 'credit_level_review', this.dataLevelReview.id, data)
          )
          if (res) {
            this.$message.success('信息编辑成功！')
            this.getLevelReview()
          } else {
            this.$message.error(`信息编辑失败，请重试！（${err.status}）`)
          }
        } else {
          data.customer_related_id = this.id
          data.customer_id = this.relatedData.customer_id
          data.customer_name = this.relatedData.customer_name
          const [res, err] = await this.$utils.promise(
            this.$api.addData('credit', 'credit_level_review', data)
          )
          this.saveLoading = false
          if (res) {
            this.$message.success('信息编辑成功！')
            this.getLevelReview()
          } else {
            this.$message.error(`信息编辑失败，请重试！（${err.status}）`)
          }
        }
      }
    },

    getRelatedData() {
      this.$api
        .getData(
          'credit',
          'customer_related_view',
          {
            'customer_related_id.eq': this.id,
          },
          { create_time: 'desc' }
        )
        .then(res => {
          this.relatedData = (res && res.data && res.data.length && res.data[0]) || {}
        })
    },

    async onReportSave(key, bankName) {
      let data = {}
      if (key === 'bank_code') {
        data.bank_name = bankName
      }
      if (this.censusData[key] !== this.reportData[key]) {
        data[key] = this.censusData[key]
        if (this.censusData.id) {
          let [res, err] = await this.$utils.promise(
            this.$api.updateData('credit', 'credit_census_report', this.censusData.id, data)
          )
          if (res) {
            this.$message.success('信息编辑成功！')
            this.getCensusData()
          } else {
            this.$message.error(`信息编辑失败，请重试！（${err.status}）`)
          }
        } else {
          data.census_status = '1'
          data.customer_related_id = this.id
          data.service_id = this.clientId
          data.customer_id = this.relatedData.customer_id
          data.customer_name = this.relatedData.customer_name
          const [res, err] = await this.$utils.promise(
            this.$api.addData('credit', 'credit_census_report', data)
          )
          this.saveLoading = false
          if (res) {
            this.$message.success('信息编辑成功！')
            this.getCensusData()
          } else {
            this.$message.error(`信息编辑失败，请重试！（${err.status}）`)
          }
        }
      }
    },
    async onCreditSave(data, id) {
      let Putdata = {}
      Putdata.remark = data
      let [res, err] = await this.$utils.promise(
        this.$api.updateData('credit', 'datum_customer_credit', id, Putdata)
      )
      if (res) {
        this.$message.success('数据采集成功！')
        this.getTopData()
      } else {
        this.$message.error(`数据采集失败，请重试！（${err.status}）`)
      }
    },
    async onCredsumbit(key) {
      let data = {}
      if (this.cardData[key] !== this.carData[key]) {
        data[key] = this.cardData[key]
        if (this.cardData.id) {
          let [res, err] = await this.$utils.promise(
            this.$api.updateData('credit', 'datum_customer_credit_card', this.cardData.id, data)
          )
          if (res) {
            this.$message.success('数据采集成功！')
            this.getCardData()
          } else {
            this.$message.error(`数据采集失败，请重试！（${err.status}）`)
          }
        } else {
          data.customer_related_id = this.id
          data.customer_name = this.relatedData.customer_name
          data.customer_id = this.relatedData.customer_id
          const [res, err] = await this.$utils.promise(
            this.$api.addData('credit', 'datum_customer_credit_card', data)
          )
          this.saveLoading = false
          if (res) {
            this.$message.success('数据采集成功！')
            this.getCardData()
          } else {
            this.$message.error(`数据采集失败，请重试！（${err.status}）`)
          }
        }
      }
    },
    async onVdataSave(key) {
      let data = {}
      if (this.postVdata[key] !== this.vdata[key]) {
        data[key] = this.postVdata[key]
        if (this.postVdata.id) {
          let [res, err] = await this.$utils.promise(
            this.$api.updateData('credit', 'datum_customer_info_verify', this.postVdata.id, data)
          )
          if (res) {
            this.$message.success('数据采集成功！')
            this.getVData()
          } else {
            this.$message.error(`数据采集失败，请重试！（${err.status}）`)
          }
        } else {
          data.customer_related_id = this.id
          data.customer_id = this.relatedData.customer_id
          const [res, err] = await this.$utils.promise(
            this.$api.addData('credit', 'datum_customer_info_verify', data)
          )
          this.saveLoading = false
          if (res) {
            this.$message.success('数据采集成功！')
            this.getVData()
          } else {
            this.$message.error(`数据采集失败，请重试！（${err.status}）`)
          }
        }
      }
    },
    // async onFinishCencus() {
    //   let data = {...this.censusData}
    //   if (!this.censusData.id) { return this.$message.warning('请先填写信息！') }
    //   data.census_status = '2'
    //   let [res, err] = await this.$utils.promise(this.$api.updateData('credit', 'credit_census_report', data.id,  data))
    //   if (res) {
    //     this.$message.success('数据采集成功！')
    //     this.getData()
    //   }else {
    //     this.$message.error(`数据采集失败，请重试！（${err.status}）`)
    //   }
    // },

    onFinishCencus() {
      this.deleteMsgBox({
        message: '确定完成（请确认信息已保存，完成后不能再修改）？',
        beforeClose: async () => {
          await this.$api.updateData('credit', 'credit_census_report', this.censusData.id, {
            census_status: 2,
          })
        },
        afterClose: this.getData,
      })
    },

    deleteMsgBox({
      title = '提示',
      message = '确定完成？',
      beforeClose = () => {},
      afterClose = () => {},
      actionMessage = '完成中...',
      successMessage = '完成成功！',
      errorMessage = '完成失败，请重试！',
    }) {
      const self = this
      this.$msgbox({
        title: title,
        message: this.$createElement('span', undefined, message),
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: async (action, instance, done) => {
          function afterSuccess() {
            afterClose()
            self.$store.dispatch('getTaskCount')
            self.$message.success(successMessage)
            instance.confirmButtonLoading = false
            instance.confirmButtonText = '确定'
            done()
          }

          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = actionMessage

            const before = beforeClose()
            if (before.then) {
              before
                .then(() => {
                  afterSuccess()
                })
                .catch(() => {
                  self.$message.error(errorMessage)
                })
            } else {
              afterSuccess()
            }
          } else {
            done()
          }
        },
      }).catch(() => {})
    },

    getImageString(images = []) {
      return images && images.length ? `["${images.map(item => item.url).join('","')}"]` : ''
    },

    handleImagesCompleteOne(images) {
      this.censusData.attachment = this.getImageString(images)
      this.onReportSave('attachment')
    },

    handleOnExceed() {
      this.$message.error('附件图片最多四张！')
    },

    handleRemove(file, fileList) {
      this.censusData.attachment = this.getImageString(fileList)
      this.onReportSave('attachment')
    },

    onPrint() {
      printHtml(
        document.getElementById('report-census').innerHTML,
        `
        .table-border-black tr > td, .table-border-black tr > th { border-color: #333 !important; font-size: 1.25rem;line-height: 1.5; }
        .table-bordered thead td, .table-bordered thead th {border-bottom-width: 1px;}
        .text-indent {text-indent: 3rem;}
        .report-title {text-align: center; margin-bottom: 1rem;  font-weight: bold; font-size: 1.6rem; line-height: 1.5; font-family: SimHei;}
        .report-census {
            width: $report-width;
            margin: 0 auto;
            padding: 2rem;
            border: 1px solid #e9ecef;
            border-radius: 2px;
            background-color: #fff;
            font-family: SimSun;
          }
          .report-section-title {
            font-size: 1.5rem;
            font-weight: bold;
            margin-top: 2.5rem;
            text-align: center;
          }
         .report-section-subtitle {
          font-size: 1.25rem;
          font-weight: bold;
          text-align: center;
          margin-top: 1.5rem;
        }
        .line {
          border: 1.5px dashed #334455;
          margin-top: 60px;
          }
        `
      )
    },

    // 编号
    onCensusNumberYearInput() {
      this.censusNumberYear = this.censusNumberYear.replace(/[^0-9]+/g, '')
      if (this.censusNumberYear.length > 4) {
        const lastChar = this.censusNumberYear[4]
        this.censusNumberYear = this.censusNumberYear.replace(/^(\d{4}).*/, '$1')
        this.$refs.censusNumberSerial.focus()
        if (!this.censusNumberSerial) {
          this.censusNumberSerial = lastChar
        }
      }
      if (this.censusNumberYear.length === 4) {
        const year = +this.censusNumberYear
        if (year > yearNow || year < yearNow - 1) {
          this.$message.error('编号年份必须是今年或去年！')
        }
      }
    },

    onCensusNumberSerialInput() {
      this.censusNumberSerial = this.censusNumberSerial.replace(/[^0-9]+/g, '')
      if (this.censusNumberSerial.length > 3) {
        this.censusNumberSerial = this.censusNumberSerial.replace(/^\d(\d{3}).*/, '$1')
      }
      if (this.censusNumberSerial === '000') {
        this.$message.error('编号必须大于0')
      }
    },

    onCensusNumberYearBlur() {
      if (!this.censusNumberYear) {
        return this.$message.error('请输入编号年份！')
      }
      const year = +this.censusNumberYear
      if (year > yearNow || year < yearNow - 1) {
        return this.$message.error('编号年份必须是今年或去年！')
      }
      if (this.censusNumberSerial) {
        if (this.censusNumberSerial === '000') {
          return this.$message.error('编号必须大于0')
        }
        this.goSaveCensusNumber()
      }
    },

    onCensusNumberSerialBlur() {
      if (!this.censusNumberSerial) {
        return this.$message.error('请输入项目序号！')
      }
      if (this.censusNumberSerial === '000') {
        return this.$message.error('编号必须大于0')
      }
      if (this.censusNumberYear) {
        const year = +this.censusNumberYear
        if (year > yearNow || year < yearNow - 1) {
          return this.$message.error('编号年份必须是今年或去年！')
        }
        this.goSaveCensusNumber()
      }
    },

    goSaveCensusNumber() {
      const num = `${this.censusNumberPrefix}-${
        this.censusNumberYear
      }-${this.getFullNumberSerial()}`

      if (num === this.reportData.census_number) {
        return
      }

      this.validateCensusNumberFromRemote(num).then(res => {
        if (res === 2) {
          this.censusData.census_number = num
          this.onReportSave('census_number')
        } else if (res === 1) {
          this.$message.error('项目编号已经存在！')
        }
      })
    },

    getFullNumberSerial() {
      return Array(3 - this.censusNumberSerial.length).join('0') + this.censusNumberSerial
    },

    validateCensusNumberFromRemote(num) {
      // eslint-disable-next-line
      return new Promise(async resolve => {
        const [res, err] = await this.$utils.promise(
          this.$api.getData(CREDIT_SERVER, 'credit_census_report', {
            'customer_related_id.eq': this.customerRelatedId,
            'census_number.eq': num,
          })
        )
        if (err) {
          this.$message.error('项目编号远程验证失败！')
          resolve(0)
        } else if (res && res.data && res.data.length) {
          resolve(1)
        } else {
          resolve(2)
        }
      })
    },
  },
  filters: {
    fixed: (v, index, fix = 2) => {
      if (index === 0) {
        return v
      } else {
        let f = Number.parseFloat(v)
        return isNaN(f) || !f ? '-' : `${f.toFixed(fix)}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
      }
    },
  },
}
</script>
<style lang="scss" scoped>
$report-width: 100%;
$report-input-border-color: #333;

.report-action {
  width: $report-width;
  margin: 1rem auto;
}

.report-wrap {
  width: $report-width;
  margin: 0 auto;
  padding: 2rem;
  border: 1px solid #e9ecef;
  border-radius: 2px;
  background-color: #fff;
  font-family: SimSun;

  .report-title {
    text-align: center;
    margin-bottom: 1rem;
    font-weight: bold;
    font-size: 1.6rem;
    line-height: 1.5;
    font-family: SimHei;
  }

  .report-section {
    margin-bottom: 1rem;

    .table-bordered td {
      border-color: #333;
      padding: 0.25rem;
      text-align: center;
      vertical-align: middle;

      &.report-input-last-td {
        border-right-color: $report-input-border-color;
      }
    }
  }

  .report-complete .report-input-td {
    background-color: #ffffff !important;
  }

  .report-section-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 2.5rem;
    text-align: center;
  }

  .report-section-subtitle {
    font-size: 1.25rem;
    font-weight: bold;
    text-align: center;
    margin-top: 1.5rem;
  }
}
.line {
  border: 1.5px dashed #334455;
  margin-top: 60px;
}
.base-bank-rate {
  width: 50px;
}
</style>
